I have a touch script where if you touch the part, it takes a model from repstore and parents it to workspace, sort of like a regen button. problem is that, when you touch it, it keeps on spawning the item from repstore constantly until you step off the block. help.
parent = script.Parent
function onTouch(hit)
wait(1)
local ItemInStorage = game.ReplicatedStorage.Floaty;
local P = ItemInStorage:Clone();
P.Parent = workspace;
wait(10)
game.Workspace.Floaty:Destroy()
end
parent.Touched:connect(onTouch)

4 comments
k thanks, im pretty sure i heard of a debounce before, but i thought it was for other things and didnt know how to do it. but thanks
wait i just realised the script doesnt seem to be working.. :/
And i just noticed an error with the debounce so I moved it up to the beginning of the if statement and it works now, if you use the edited code it should work
If it still doesn't work just tell me, and I'll do my best to fix it