I want to make a reloading animation for my gun.
My Debounce wont work and I do not know how to make it work on the server with my script
DevForum
I am using the Client (LocalScript)
and I am trying to make it so that they can’t spam reload and so that when the weapon is equipped they can reload. But when the weapon isn’t equipped it will still play it if I click "R"
on my keyboard. This is used with UserInputService
. The LocalScript is inside of the tool not the player and I do not understand how to make it Debounce from the Server (Script)
game:GetService("UserInputService").InputBegan:Connect(function(key,gameP)
local result = ""
if key.KeyCode == Enum.KeyCode.R or key.KeyCode == Enum.KeyCode.ButtonX and result == "" and held == true and not gameP then
result = "Playing"
idleAnim:Stop()
wait()
shootAnim:Stop()
wait()
reloadAnim:Play()
wait()
reloadAnim.Stopped:Wait()
idleAnim:Play()
wait(0.5)
result = ""
elseif result ~= "" and held ~= true then
return nil
end
end)