Hello!
I have a local script and a script (Credits to @EmbatTheHybrid for the both scripts) There is a small problem though, the player is able to glitch the button by spam clicking it.
Example of the problem: https://gyazo.com/612a6a693c3a772f364e71480a7d4f08
I have tried adding a debounces to the scripts to prevent spam clicking, but it didn’t work.
(Either am writing them wrong or placing them in the wrong place.)
Please help! 
You can probably have it so in the Server script, you have a table of people who are currently teleporting
local teleportingPlayers = {}
And in your if statement, check as well if they are already teleporting
if leaderstats and Time and not teleportingPlayers[player.Name] then
And then make it so before the repeat loop, it sets their key’s value in the dictionary to true
teleportingPlayers[player.Name] = true
And then when the teleport has ended, either because they moved or the teleport finished, just set their thing in the dictionary to nil
teleportingPlayers[player.Name] = nil
It’s better to do a server sided debounce because exploiters can just reenable the localscript to set the debounce again to spam, and just in general server sided debounces are harder to exploit
2 Likes
Would this debounce method work?
local Debounce = true
button.Activated:Connect(function()
if Debounce == true then -- Locks it if the debounce is false
Debounce = false -- Makes the debounce false so the player cannot click it again
timeCheckAndTeleport:FireServer()
wait(4)
Debounce = true -- Returns it to true so the player can click it again
end
end)
1 Like
That can work as well but how will the localscript know the teleport has finished so it can be used again? Also, again, exploiters can jsut reenable the localscript I believe and they can activate it again, a server-sided debounce is more effective in this case
1 Like
Hi @EmbatTheHybrid, After trying your script it worked but the script will not function after and if the player moves.
The script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local timeCheckAndTeleport = ReplicatedStorage.TimeCheckRemoteEvent -- References a RemoteEvent called "TimeCheckRemoteEvent" in the ReplicatedStorage
local teleportingPlayers = {}
timeCheckAndTeleport.OnServerEvent:Connect(function(player) -- Function is called when RemoteEvent is activated on the server
local leaderstats = player:FindFirstChild("leaderstats")
local Time = leaderstats:FindFirstChild("Time Alive")
if leaderstats and Time and not teleportingPlayers[player.Name] then-- If player has leaderstats folder and Time leaderstat, then...
local timeCheck = Time.Value and Time.Value >= 1
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local playerGui = player:WaitForChild("PlayerGui")
local label = playerGui.ScreenGui.TextButton
local currentTime = 3
local hasMoved = false
label.Text = currentTime
teleportingPlayers[player.Name] = true
repeat
currentTime -= wait(0.1)
if Humanoid.MoveDirection ~= Vector3.new() then
hasMoved = true
label.Text = "Player moved!"
wait(2)
label.Text = "Teleport"
break
end
label.Text = math.ceil(currentTime)
until currentTime <= 0 or hasMoved
if hasMoved then
return
end
teleportingPlayers[player.Name] = nil
if timeCheck and Character and Character.PrimaryPart then -- If they have 500+ time and their Character & its PrimaryPart exists, then...
local newCFrame = CFrame.new(-74.66, 18.598, -39.968) -- Defines new CFrame value
label.Text = "Teleport"
Character:SetPrimaryPartCFrame(newCFrame) -- Teleports the player to the newCFrame value
end
end
end)
1 Like
Put teleportingPlayers[player.Name] = nil
before the if hasMoved then
if statement so
teleportingPlayers[player.Name] = nil
if hasMoved then
return
end
Because if you moved, it can’t set you out of the dictionary because you placed it after the if statement
2 Likes
Wow! It worked, Thanks again @EmbatTheHybrid. 
1 Like
Anytime! If you have anymore issues don’t be afraid to make another post!
1 Like