Enhance script property encoding in encodeInstance.lua

- Updated the encodeInstance function to include additional script properties (Disabled, LinkedSource, etc.) for encoding into the .meta.json5 file.
- Improved handling of properties by skipping those that are already managed or should be ignored, ensuring only serializable properties are encoded.
- Clarified comments to indicate the necessity of encoding the Source property.
This commit is contained in:
Joe 2026-01-30 12:55:53 -06:00
parent 439eb3f5f8
commit c0d089f0aa

View file

@ -147,7 +147,7 @@ encodeInstance = function(instance, parentId, _skipPathCheck)
encodeAttributes(instance, properties)
if SCRIPT_CLASS_NAMES[instance.ClassName] then
-- For scripts, encode the Source property
-- For scripts, encode the Source property (required)
local sourceDescriptor = RbxDom.findCanonicalPropertyDescriptor(instance.ClassName, "Source")
if sourceDescriptor then
local encodeSuccess, encodeResult = encodeProperty(instance, "Source", sourceDescriptor)
@ -162,14 +162,25 @@ encodeInstance = function(instance, parentId, _skipPathCheck)
return nil
end
-- For Script class specifically, also encode RunContext property
-- This determines the file suffix (.server.luau, .client.luau, .plugin.luau, .legacy.luau)
if instance.ClassName == "Script" then
local runContextDescriptor = RbxDom.findCanonicalPropertyDescriptor("Script", "RunContext")
if runContextDescriptor then
local encodeSuccess, encodeResult = encodeProperty(instance, "RunContext", runContextDescriptor)
-- Also encode other script properties (Disabled, LinkedSource, etc.)
-- These go into the .meta.json5 file
local classDescriptor = RbxDom.findClassDescriptor(instance.ClassName)
if classDescriptor then
for propertyName, propertyDescriptor in classDescriptor.properties do
-- Skip properties we handle separately or should ignore
if SKIP_PROPERTIES[propertyName] then
continue
end
if propertyName == "Source" or propertyName == "Attributes" then
continue
end
-- Only encode serializable properties
if propertyDescriptor.scriptability == "ReadWrite" or propertyDescriptor.scriptability == "Read" then
local encodeSuccess, encodeResult = encodeProperty(instance, propertyName, propertyDescriptor)
if encodeSuccess and encodeResult ~= nil then
properties.RunContext = encodeResult
properties[propertyName] = encodeResult
end
end
end
end