Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Character won't load animation?

Asked by 4 years ago

I don't know much about making animations, but I know how to play them (i think). Whenever I try to load the animation, it does nothing. Output doesn't say it didn't load, and sometimes when i walk or jump the animation plays but it didn't play in the moment. Help? This is the script, broken down to the more important parts. (its a vent for an among us copy by the way, making the player jump in felt lazy)

animEnter = p.Parent.ventEnter
local c = plr.Character
local h = c.Humanoid
local ventplay = h:LoadAnimation(animEnter)
-- variables
p.ClickDetector.MouseClick:Connect(function(plr)
    if plr.Character.Torso.Transparency == 0 and plr.IsTraitor.Value == true then
    ventplay:Play()
    end
end)
--code

There's a lot more to the script, but I broke it down to what I need. Everything is good, traitor value is true, torso is opaque. I just don't understand, did I code wrong or is it my crappy PC?

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Hmm, well I am not the best at analyzing code, this is my animation script and it would certainly work. I learned this from alvinblox I THINK, anyways you can use it to see if you made any mistakes.

local Animation = Instance.new("Animation")
Animation.AnimationId = "http://www.roblox.com/Asset?ID=5921046448"

local AnimationTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()

Remember animations are to be played through localscripts. Also, maybe you can add the whole code if this doesn't help.

0
it was in a server side, thank you AbsurdAwesome101 56 — 4y
Ad
Log in to vote
2
Answered by 4 years ago

It seems like the problem is that the character hasn't load yet, therefore the animation can't load. Since animations play through a local script, you should define the local player.

animEnter = p.Parent.ventEnter
local player = game.Players.LocalPlayer
local character = player.Character or player.PlayerAdded:Wait() --Define character
local humanoid = character.Humanoid
local ventplay = humanoid:LoadAnimation(animEnter)
-- variables
p.ClickDetector.MouseClick:Connect(function(plr)
    if plr.Character.Torso.Transparency == 0 and plr.IsTraitor.Value == true then
    ventplay:Play()
    end
end)
--code
1
also thank you for your answer i can't accept since i already did someone else's but i will upvote AbsurdAwesome101 56 — 4y

Answer this question