#how to make a cooldown on touch event

1 messages · Page 1 of 1 (latest)

vapid trout
#

okay lets say someone touched my block and died but in console i can see hum.Health = 0 multiple times i want to do cooldown on this to get better optymalization and performance for my game

how?

pliant phoenix
#

do a cd

#

jk

#

exemple

#

local OnTouchCD = [false,1}

thing.touched:Once(function() -- or use connect
if OnTouchCD[1] == false then
OnTouchCD[1] = true
task.spawn(function()
task.wait(OnTouchCD[2])
OnTouchCD[1] = false
end
end)

hybrid vesselBOT
#

studio** You are now Level 15! **studio

vapid trout
#

Alr but when someone will touch this thing other people need to wait 1 sec to touch it too and this is a problem

modern coral
#

just check if the player has already touched the part or not

vapid trout
#

okay but how?

hybrid vesselBOT
#

studio** You are now Level 1! **studio

modern coral
#

just use :SetAttribute on the player and add a boolean

#

then put an if statement that returns the whole function if the character that touched it belongs to that player

#

i think you'll have to use task.delay

#

idrk 🤷