Hello I Need your help,can someone add a cooldown to this script,like wait (5) thingy,(i tried to add wait(5) but it doesnt work
Heres the script:
function onTouch(part) local Toucher = part.Parent:FindFirstChild("Humanoid")
if Toucher ~= nil then Toucher.Torso.CFrame = CFrame.new(-11.97, 0.5, 53.22)--where you place the cordinants and to do that --you have to place a part then open properties slect the part look at position then put the code in --there end
end
brick = script.Parent brick.Touched:connect(onTouch)
please edit it and just add a cooldown
Adding a wait won't do anything without a debounce. Every time the Touched event is fired, the wait will be ignored. A debounce will prevent the code from running even if the event connects.
local debounce = true script.Parent.Touched:Connect(function(hit) -- Is hit and touchable if hit and hit.Parent and debounce then -- Is Player? local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player then -- Is Humanoid local Humanoid = Player.Character:FindFirstChild("Humanoid") -- Is player alive if Humanoid and Humanoid.Health > 0 then -- set debounce to prevent spam debounce = false Player.Character:SetPrimaryPartCFrame ( CFrame.new(-11.97, 0.5, 53.22) ) end end wait(3) -- reset debounce debounce = true end end)
just add a wait()
if Toucher ~= nil then Toucher.Torso.CFrame = CFrame.new(-11.97, 0.5, 53.22) wait() ---- how long you want to cool down end