Hello, I have a problem with the code, namely when I try to Clone every 60 seconds an object from ServerStorage and copy its Parent to the workshop. The problem arises when you copy an object, every 60 seconds its copy is created infinity I wanted to set the IF to break it somehow but I don't know how to go about it, I tried all the ways with FindFirstChild break etc
Here Code pss i am newbie with coding if u are to know Don't laught if here get a mistakes:
local ServerStorage = game:GetService("ServerStorage") local parts = ServerStorage.TreasureChest local timer = 5 while wait(timer) do for _,chests in pairs(game.Workspace.Folder:GetChildren())do
if not chests:FindFirstChild("TreasureChest") then
print("its model doesn't exists!")
-- Clone from ServerStorage to Workspace folder
local elo = parts:Clone()
elo.Parent = game.Workspace.Folder
local HealthChest = Instance.new("IntValue",parts)
HealthChest.Name = "HealthChest"
HealthChest.Value = tonumber(math.random(1250,2500))
break
elseif chests:IsA("Model") and chests.Name == "TreasureChest" then
print("model exists!")
chests:SetPrimaryPartCFrame(CFrame.new(-4,-10,math.random(0,150))* CFrame.Angles(0,math.random(0,360),0))
break
end
end
end
Here are image the problem are checked red color: https://ibb.co/S5rrXJK
