Sorry for the silly title, anyways:
I want to clone one item every second if a player touches an object, but with this script, the object is cloned like crazy.
local spawner = game.Workspace.ToothpasteSpawner local detector = script.Parent local ball = game.ServerStorage.DeathBall local function spawnBall (part) local humanoid = part.Parent:FindFirstChild("Humanoid") if humanoid then local ballClone = ball:Clone() wait(1) ballClone.Parent = game.Workspace ballClone.Position = spawner.Position wait(1) end end detector.Touched:Connect(spawnBall)
Simply add a debounce
. Here's your code with the debounce inserted.
local spawner = game.Workspace.ToothpasteSpawner local detector = script.Parent local ball = game.ServerStorage.DeathBall local db=false local function spawnBall (part) local humanoid = part.Parent:FindFirstChild("Humanoid") if humanoid and not db then db = true local ballClone = ball:Clone() ballClone.Parent = game.Workspace ballClone.Position = spawner.Position wait(1) db =false end end detector.Touched:Connect(spawnBall)
If I answer solved your problem please remember to accept it. It helps me out a lot!