-
What do you want to achieve? a debounce for this ability
-
What is the issue? the debounce doesnt work and the player can fire the event multiple times
-
What solutions have you tried so far? none
here’s the script:
-- services, variabled and functions
local UserInputSerice = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer
local character = player.Character
local debounce = false
local PBEvent = ReplicatedStorage.PBEvent
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://" -- add your AnimationId after the //
local anim = character.Humanoid:LoadAnimation(Animation)
-- code
UserInputSerice.InputBegan:Connect(function(input, gameprocessed)
if gameprocessed then return end
if input.KeyCode == Enum.KeyCode.X and debounce == false then
anim:Play()
PBEvent:FireServer()
end
task.wait(10)
debounce = false
end)
all help is appreciated