What you need is to use AnimationTrack.Priority, so you need to set the animation priority for your BatonAnimation to action, so it overrides roblox's default animations. It can be done as shown:
local Player = game.Players.LocalPlayer.Name
local Character = player.Character
local BatonAnimation= pl.Humanoid:LoadAnimation(script.Parent.BatonAnimation)
BatonAnimation.Priority = Enum.AnimationPriority.Action
local debounce = true
script.Parent.Activated:Connect(function()
if debounce then
debounce = false
planimation:Play()
wait(0.5)
debounce = true
end
end)
Since this answers your question, then mark it as the accepted answer.
And here are some things you need to understand about the basics of scripting:
So from inside a local script, you can get the player's character directly by getting the localplayer, and then referencing the character property of the player. It makes it much easier and you don't need to mess with any WaitForChild stuff. And since this is in a tool, you also don't need to wait for their character to load because the tools get loaded after the character does.
Also, your naming conventions are a bit unhelpful when explaining exactly what the variable means. Anyone should be able to look at the variable anywhere in your script and be able to get a gist of what it is referring to.
Third, your debounce using an integer is a bit inefficient, it is better to use a boolean value so that you can just check its value by doing if debounce then rather than using if debounce == 0 then, its just shorter and it uses up less resources even if its not much to really matter.
And last, you need to keep Roblox's default indentation, when I copied your code, I noticed you deleted the proper indents and replaced them with your own 2 space indents. Its not a problem in that it would make your code not work, its just that keeping the original indents makes your code easier to read and find errors in.
4 comments
Is it a LocalScript?
Yes
you don't need to wrap a string in "tostring"
Did I answer your question, or are you confused by anything still?