My script that is supposed to delete a gui once, deletes it twice, any help with this?
local GiveBack = Instance.new("RemoteEvent") GiveBack.Parent = game.ReplicatedStorage GiveBack.Name = "GiveLitBack" script.Parent.Touched:connect(function (hit) if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then local plr = game.Players[hit.Parent.Name] if plr.PlayerGui:WaitForChild("Tattoo2") then plr.PlayerGui:WaitForChild("Tattoo2"):Destroy() GiveBack:FireClient(plr) end end end)
You need to use a Debounce like this
local GiveBack = Instance.new("RemoteEvent") Debounce = false GiveBack.Parent = game.ReplicatedStorage GiveBack.Name = "GiveLitBack" script.Parent.Touched:connect(function (hit) if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) and not Debounce then Debounce = true local plr = game.Players[hit.Parent.Name] if plr.PlayerGui:WaitForChild("Tattoo2") then plr.PlayerGui:WaitForChild("Tattoo2"):Destroy() GiveBack:FireClient(plr) wait(2) Debounce = false end end end)