Help with tool respawning script

I think the problem is while true do, because you want every 5 seconds since pick up, but while true do does it every 5 seconds constantly. I’ve solved it by making spawners so the tools won’t have to carry the script, and have a backup inside replicated storage

local debounce = false

while wait() do
	if script.Parent:FindFirstChild("Steve") == nil and debounce == false then
		debounce = true
			wait(5)
			local Backup = game.ReplicatedStorage.Steve:Clone()
			Backup.Handle.CFrame = script.Parent.CFrame
			Backup.Parent = script.Parent
		debounce = false
	end
end

I had the 5 second wait as a test, in actuality I was going to change that to 5 minutes or something. The is about scavenging for items in the wilderness, so having each item have a different spawning time makes the game a lot more challenging and rewarding.

Oh, I think the only problem with the script is that it might lag, since it’s checking if it still contains the item in every little second

1 Like

I think you might have to ask another question like “How to reduce lag in script”, or “will this cause lag”

1 Like