Hi, I have recently been trying to create a script where fires cannot be cloned in a part or object non stop, and this script does that. However, I only want one fire object to be present in the part, not hundreds of them which I use another cloning script for.
This is my code:
while wait() do for i, v in pairs (script.Parent:GetChildren()) do if v then if v.Name == "Fire" then for i = 1, (#v -1) do --Error line v:Destroy() wait() end end else return end end end
Line 5 seems to be the error in the output. This is what is printed in the output: Workspace.DanielRocky.HumanoidRootPart.OneFireOnly:5: attempt to get length of local 'v' (a userdata value)>
Help please?
while wait() do local fireObjects = {} -- Creates empty tabled called "fireObjects" for i, v in pairs (script.Parent:GetChildren()) do if v then if v.Name == "Fire" then table.Insert(fireObjects, v) -- Inserts all of the "Fire" objects that are in Humanoid RootPart into the fireObjects table. for i = 1, (#fireObjects -1) do --This instead gets how many objects that are in the table. v:Destroy() wait() end end else return end end end
Hope this helps!