@P1X3L_K1NG
It doesn’t seem to work yet. Have you tested it and is there something really small that I’m missing? Here’s what I’m working with: anim.rbxl (22.2 KB)
I changed
to just
but it would be nice to know exactly the difference between those two. I mean I see that one of them is waiting for a short time, but why is that necessary if you’re saying the other one works?
You need to include both, the “or” is part of the script:
local char = player.Character or player.CharacterAdded:Wait()
Sometimes the player’s character won’t be ready when you want it. So you want to include the or player.CharacterAdded:Wait()
This pauses the script and waits for the character to load before continuing. You can think of it as “the character isn’t here yet, let’s wait a sec for it to load.”
I’m about to go to bed, so I’ll have to visit your place file in the morning.
The reason it does not work is because there is no animation in the LocalScript.
Create an Animation object, paste the ID inside of it, then place it inside the LocalScript inside of your button. You’re explorer window should look like this:
I checked all your scripts, and they look good. The problem was that you didn’t even have an animation to play. If you still have a problem, let me know
local tableOfCooldowns = {}
game:GetService('ReplicatedStorage'):WaitForChild('RemoteEvent').OnServerEvent:Connect(function(plr, otherArguments)
if tableOfCooldowns[plr] and os.clock() - tableOfCooldowns[plr] < 1 then return end -- 1 second cooldown
tableOfCooldowns[plr] = os.clock() -- Set it to os.clock so we can use it again.
--[[
Why do we need a table to make a cooldown? Well placing the remote event on replicated storage
makes it global meaning every single person fires 1 remote and if you had a cooldown
with no table, it would make a global cooldown. Let's say you have 1 second of debounce
when one person fires the remote, in the next 1 second(cooldown length) nobody can fire.
Well, they can fire but can't get past the cooldown meaning they can't execute the thread below the cooldown.
]]
-- plr would be the player who has fired the remote event
-- the first argument is ALWAYS the player who has fired the remote, you can add more onto it after plr by simple using commas
end)