Guys idk how to make a debounce system to avoid spam issue so can anyone edit my script and make debounce system on it and ty
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Character = player.CharacterAdded:Wait()
local humanoid = Character:WaitForChild("Humanoid")
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:connect(function(keyCode)
local HRP = Character:FindFirstChild("HumanoidRootPart")
if keyCode.keyCode == Enum.KeyCode.D then
while keyCode.keyCode == Enum.KeyCode.D do
Character:MoveTo(HRP.Position + Vector3.new(0,0,1))
end
end
end)
Note : the script idea is make player move right if he hold D (don’t ask me why)