Thanks I’ll be sure to try that and see if it works
If the template is in replicated storage/server storage you can also just leave the script enabled (since it won’t run until it’s out)
If you have multiple scripts in the descendants of the item then the script which you provided will only get one of the scripts then Enable it and ignore the rest, to fix this, create a table and store all of the script instances in there, and use another for i, v in ipairs loop to manipulate the property Enabled
for each individual script in the table. You can clear the table later if you want.
local all_scripts = {}
for _, scriptObject in ipairs(item:GetDescendants()) do
if scriptObject:isA("Script") then
table.insert(all_scripts,scriptObject)
end
end
for i , v in ipairs(all_scripts) do
v.Enabled = true
end
Tell me if it works.
I think that you have to use ipairs
instead of pairs
as I got a silent error while iterating through players with pairs, but when I changed it to ipairs, it worked. Test it and tell me if it works.
Also, @yousefoyoy, that doesn’t change nothing. GetDescendants returns a table with Instances, and you’re just inserting that table content to another table.
Actually you don’t really need pairs or ipairs in Roblox because it uses Luau. It’s actually slightly faster not to sometimes (in writing and in speed) so that shouldn’t really matter (and in this case, it doesn’t matter what order the instances get checked)
But ipairs iterates through tables in a different way than pairs.
Yes, I know that, but I was just pointing out that neither versions mattered in this case
I think that pairs can’t iterate through arrays, and GetDescendants returns arrays, so?
I disagree, I’ve used this method many times and it always works. For example: if I have an if
statement inside a for i , v in ipairs(whatever)
it will only loop through one of the instances which is in the whatever
and the script just breaks.
pairs can iterate both dictionaries and arrays but doesn’t iterate in order. ipairs, though faster, can only iterate through arrays and is in order, skipping nil values. However, generalized iteration is better now.
OP, run your game and check if the script is being enabled in the explorer view. If so, it might just be the script itself somehow not working.
when I switched it to ipairs, nothing changed, so this doesnt work
Did you try the script I provided?
I tested it and it sadly didnt change a thing
I think instead of showing us a small code block, why not make a separate place file for us to inspect and see the full picture of the bug, you don’t have to copy over the entire game, only elements that is required to reproduce the issue.
Try this. If it’s missing, make sure Archivable is turned on. If it’s not being enabled at all, assure that you are cloning the right object and/or it is actually a Script.
Hey guys…?
Can you look at this?
local all_scripts = {}
for _, scriptObject in ipairs(item:GetDescendants()) do
if scriptObject:isA("Script") then
table.insert(all_scripts,scriptObject)
end
end
for i , v in ipairs(all_scripts) do
v.Enabled = true
print(v.ClassName)
end
Is this a prank? Because, um…
Let’s just say it still doesnt enable the script for the conveyor.
Oh yeah, look at this too.
(This shows that it is disabled)
Ah. Do Disabled = false
instead of Enabled = true
.
Why don’t you use disabled instead like Script.Disabled = false
Here’s some information I found: