So, i wanted a script that removes all targets and replaces them with a :Clone()
This is my script
wait()
local NewScript = script.LightScriptV2
wait()
for _,v in pairs(workspace:GetChildren()) do
wait()
if v:findFirstChild("LightScript") then
NewScript:Clone()
NewScript.Parent = v.Parent
print(NewScript.Parent)
v:Destrioy()
print("Changed. "..v.Name)
else
print("Not changed "..v.Name)
end
end
It keeps printing the print("Not changed "..v.Name) line, instead of replacing.
The object he needs to find are in different models in Workspace.
Can someone explain me what i'm doing wrong?
EDIT: I CHANGED THE SCRIPT AS RECOMMEND BELOW.
But still, it doesn't do anything...
(the new script recommended by users in comments)
wait()
local NewScript = script.LightScriptV2
wait()
for _,v in pairs(workspace:GetChildren()) do
wait()
if v:FindFirstChild("LightScript") then
NewScript:Clone().Parent = v
v:Destroy()
print("Changed. "..v.Name)
else
end
end

2 comments
I think you just need to capitalize the 'f' in 'findFirstChild', line 7
not really, but good catch