I have this script… What do i change so it wait 5 sec before it do it again?
local part = script.Parent
local function OnTouched(OtherPart)
local humanoid = OtherPart.Parent:FindFirstChild("Humanoid")
if humanoid then
OtherPart.Parent:ScaleTo(0.5)
wait(5)
end
end
part.Touched:Connect(OnTouched)
So like a cooldown? You can make a debounce variable and make it do the function if debounce is false, and not if true.
local part = script.Parent
local debounce = false
local function OnTouched(OtherPart)
if debounce then
return
end
debounce = true
local humanoid = OtherPart.Parent:FindFirstChild("Humanoid")
if humanoid then
OtherPart.Parent:ScaleTo(0.5)
wait(5)
end
debounce = false
end
part.Touched:Connect(OnTouched)
i suppose you could create a table, everytime a player touches the part their username is added into the table. every player’s username on the table won’t get affected by the part if touched again.