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

Animation script works in studio but not in game. Why?

Asked by 9 years ago

Hello! I've been trying these scripts with my animation and neither of them work.

The first one is in ServerScriptService and is a normal script. The other is in a block. The second one is there because I can't seem to figure out how to make the animation come back once the player dies. The script is also a normal script Can you please help me?

I've tried making a humanoid.Died script and putting it into the startergui/starterpack/serverscriptservice and neither one of them worked.

It doesn't provide any errors because it works in studio. But not in game. So I'm quite stuck.

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        local findanimate = character:FindFirstChild("Animate")
        findanimate:WaitForChild("walk"):WaitForChild("WalkAnim").AnimationId = 'http://www.roblox.com/asset/?id=294556403'
        wait(1)

    end)
end)

Above: The script in serverscriptservice. Below: The script inside a part to reset the animation if a character dies.

function onTouched(hit)
local animate = hit.Parent.Parent:WaitForChild("Animate")
local walkanim = animate:WaitForChild("walk")
print("lol")
walkanim:WaitForChild("WalkAnim").AnimationId = 'http://www.roblox.com/asset/?id=294556403'
print("lol2")
end

script.Parent.Touched:connect(onTouched)

Thank you for any help in advance.

P.S. I've been trying to fix this for about 5 days now. :/

0
Anyone? TheNoobBoss1012 0 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

I think that you need to put the animation code in a localscript under the player's playergui/character/backpack

0
I've alreaady done that. The character is where the animations are stored and the backpack is the starterpack. I've already tried both script and localscript. I've also already said I've tried the playergui and the backpack. TheNoobBoss1012 0 — 9y
Ad
Log in to vote
0
Answered by 9 years ago
  1. You dont need to add a script that changes it when the player dies because it doesnt change when the player dies.
game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(Character)
        wait()
        print("Animations Changing")
        if Character:findFirstChild("Animate") then
                Character.Animate.walk.WalkAnim.AnimationId = "'http://www.roblox.com/asset/?id=294556403"
        else print("Character has no animation") 
        end
    end)
end)

This script checks if animate is in the player and if so changes the walk animation inside of it. :P Click accept answer if this helped :D

0
I just checked and it's still the default animation in-game. TheNoobBoss1012 0 — 9y

Answer this question