Hi, thank you for reading. What I'm trying to do here is that after every 2 seconds, if there is no object in workspaced named "Foil", then the script will fire and a "Foil" from Lighting will clone into the workspace. The problem is that it keeps spawning the foil after I removed it when I clicked it. It just spawns infinitely and it bothers me that it does that. Can anyone help me?
Material = game.Lighting.Loot:getChildren()
Foil = game.workspace:WaitForChild("Foil")
while wait() do
print("Spawning")
wait(2)
for i = 1, #Material do
if Material[i] and Material[i]:findFirstChild("Foil") then
if Foil.Parent ~= game.workspace then
Materials = Material[i]["Foil"].Parent:Clone()
Materials.Parent = workspace
Part = game.Workspace.Part
if Part ~= nil then
Materials:MoveTo(Part.Position)
end
end
end
end
end

2 comments
No, it's a different question now.
Oh