**I tried adding a model that would hold all of these in and delete the model but that does not work since this is a touched event what it does it it said I touched it once though and the message repeats like 8 times I want this message only made 1 not 8 hints between an I don't mean hints that are different but with the same text no output either **
function onTouch(hit) local name = hit.Parent.Name local plr = hit.Parent:FindFirstChild("Humanoid") if plr then local check1 = game.Players:GetPlayerFromCharacter(hit.Parent) if check1 then local check2 = check1:WaitForChild("leaderstats") if check2 then local check3 = check2:WaitForChild("Owner") if check3.Value == true then local m = Instance.new("Hint",game.Workspace.Hints) m.Text = name.." Already Owns A Tycoon" wait(7) game.Workspace.Hints:Destroy() wait(7) end if check3 then check3.Value = true script.Parent.CanCollide = false script.Parent.Transparency = 1 print(hit.Parent) end end end end end script.Parent.Touched:connect(onTouch) wait(1)
Debounce is a technique used to limit the number of times an event can be triggered. You could compare this to the firing speed of a gun, the attack speed of a weapon, or the cooldown of a skill. The basic idea of debounce is to make sure no actions are performed while the event is inactive.
For example, let's use a simple Touch event.
local brick = script.Parent local enabled = true --represents whether the event is "cooling down" brick.Touched:connect(function(other) if enabled then --will not activate unless enabled print("You just activated my trap card!") --performing normal actions enabled = false --disabling so that the function cannot be activated again wait(1) --the cooldown time enabled = true --re-enabling so that the touch can be activated again else print("My trap card is on cooldown!") --print this if the block is touched while on cooldown end end)
In this code sample, a brick will print "You just activated my trap card!" when touched, then enter a disabled state in which it will not print out the same message until one second later, in which enabled
is set back to true
. Until it resets, the block will just print out "My trap card is on cooldown!".