I'm working on touch detection, but when I go to test it out, the detection spams between being touched, and the touch ending when I haven't stepped off? What can I do to stop this spam?
local buttonPressed = false script.Parent.Touched:Connect(function(part) local parent = part.Parent if game.Players:GetPlayerFromCharacter(parent) and buttonPressed == false then local player = game.Players:GetPlayerFromCharacter(parent) player.PlayerGui.BuyMoves.Enabled = true end end) script.Parent.TouchEnded:Connect(function(part) local parent = part.Parent if game.Players:GetPlayerFromCharacter(parent) then buttonPressed = false local player = game.Players:GetPlayerFromCharacter(parent) player.PlayerGui.BuyMoves.Enabled = false end end)
Thanks!
Debounce
local debounce = false something.Touched:connect(function() if debounce then return end debounce = true --code wait(.5) debounce = false end)