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

Why isn't my animation command not working?

Asked by
Seraine 103
9 years ago

This script should check if you're in a certain group, if you are then if you say "/e party", your character performs the animation. If you're not a member of the group, nothing happens if you say the command. Also how should I make the animation looped? Right now it just plays once :L

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg == '/e party' and player:IsInGroup(846314) then
            player.animationID = 172807805 --id of animation
            script:remove()
        end
    end)
end)

2 answers

Log in to vote
1
Answered by 9 years ago

This may be what you want. The explaination is given by bobafett3544 so I dont need to tell you why.

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg == '/e party' and player:IsInGroup(846314) then
            player.animationID = 172807805 --id of animation
            script:remove()
        end
    end)
end)


0
I tried that but it still doesn't play the animation... Seraine 103 — 9y
0
Then i have failed as a human being. ConnorVIII 448 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

On line 3, you put player:IsInGroup(846314) ~= true. ~= true means "is not true", so if you're in the group, the animation will not play. Change that to player:IsInGroup(846314). Also, to loop it, open the animation in the animation editor and check the "Loop" box.

EDIT: Put an animation object with the right animation ID in the script. The code I'm giving you here needs an animation.

game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
if msg == '/e party' and player:IsInGroup(846314) then
local animation = script:FindFirstChild("Animation")
local animTrack = player.Character:WaitForChild("Humanoid"):LoadAnimation(animation)
animTrack:Play()
end
end)
end)

Note that this code will not stop playing the animation if it is looped. I'll find a way to make it stop when I get home and have access to Studio.

Answer this question