I uploaded an animation to Roblox, I wrote a script to play the animation, and it didn’t play. I then tried making a group then uploading the game and the animation to the group, still nothing. Although, on both instances, other animations I have made on my account do work. I made these new animations with Moon Animator 2 (Up to date). I even imported the animation to Roblox’s built in animator plugin, and then uploaded it from there. Still no luck. I have been trying to fix this for days, please help me.
Could you show the script? That would be really helpful.
Note: that this works with any animation that isn’t the one I want
script.Parent.RequiresHandle = false
anim = script:WaitForChild("punch")
char = game.Players.LocalPlayer.Character
script.Parent.Activated:Connect(function()
print("punch")
local a = game.Players.LocalPlayer.Character.Humanoid.Animator:LoadAnimation(anim)
a.Priority = Enum.AnimationPriority.Action
a.Looped = false
a:Play()
print("playing")
a.Ended:Wait()
print("executed")
end)
bump because nobody is responding
Just doing straightforward indexing is risky, especially when it’s with tools. Anything could go wrong here. It’s entirely possible that the character hasn’t fully loaded yet when the script ran.
Try this out instead:
local PS = game:GetService("Players")
local tool = script.Parent
tool.RequiresHandle = false
local anim = script:WaitForChild("punch")
local player = PS.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum: Humanoid = char:WaitForChild("Humanoid")
local animator: Animator = hum:WaitForChild("Animator")
local punchAnim = animator:LoadAnimation(anim)
punchAnim.Priority = Enum.AnimationPriority.Action
punchAnim.Looped = false
tool.Activated:Connect(function()
punchAnim:Play()
print("playing")
punchAnim.Ended:Wait()
print("executed")
end)
Do note that the code above should ONLY be used for LocalScripts, if you want to use a normal Script, use this code instead:
repeat task.wait() until script.Parent.Parent.Parent:IsA("Player") --@ this is to avoid any nasty errors like "Cannot load the AnimationClipProvider service"
local tool = script.Parent
tool.RequiresHandle = false
local anim = script:WaitForChild("punch")
local player = tool.Parent.Parent
local char = player.Character or player.CharacterAdded:Wait()
local hum: Humanoid = char:WaitForChild("Humanoid")
local animator: Animator = hum:WaitForChild("Animator")
local punchAnim = animator:LoadAnimation(anim)
punchAnim.Priority = Enum.AnimationPriority.Action
punchAnim.Looped = false
tool.Activated:Connect(function()
punchAnim:Play()
print("playing")
punchAnim.Ended:Wait()
print("executed")
end)
I’ve tested both scripts with my own animation, these should work for you.
Thank you but, this isn’t the problem. Yes, I did try it. Although, as I said before, other animations work, just not the one I made. Besides, that script I gave was my rough draft, not at all the final.
The only thing you can do now is wait. Maybe just waiting it out or restarting Studio may fix it?
Already tried restarting Studio, and as I said I have tried this for 2 days.
Oh yeah, if you’re playing multiple animations at the same time, one may cancel out / not play.
ESPECIALLY animations with the same priority
I only have 1 animation in the whole game as of right now, I haven’t gotten to make anything else because I cant get the animation to work.
Is the animation id set (for the animation object)
Animation.AnimationId = -- your anim id here
Yes, I even tried setting it via the script and still no luck.
Could you potentially send me the animation ID? Just to double check.
I know it’s worked for you before but make sure you correct set the Animation.AnimationId to “rbxassetid://myanimid”
Edit: I’m going to try the animation myself
Of course it’s rbxassetid://13633199714
Animation works fine for me, maybe try using the animation spoofer plugin to spoof it, and make sure you publish the animation under the same owner of the game you’re trying to use it in:
e.g. If your game is under your group, publish it under your group.
If it still doesn’t work, it’s likely an issue with your script. This is how i loaded it:
local anims = {
["Animation"] = "rbxassetid://13633320918";
}
-- preload anim
for name, id in pairs(anims) do
local anim = Instance.new("Animation")
anim.AnimationId = id
anims[name] = hum:LoadAnimation(anim)
end
anims.Animation:Play()
I tried uploading it to the group, and my own account. What is the link to the animation spoofer? I can’t find it.
This is the one i use, just open the plugin and copy paste the anim id and click convert, you should be met with a preview of your anim above the convert button. Then upload that and copy the new ID.
That didn’t fix it, any other ideas?
Did you try putting my script in and pasting your ID in the anims array? If that works then it’s most likely an issue with your script
I’m using your script now, and yes I tried that.