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

How to change Player default animation in the flow of the game (not on player add)?

Asked by 6 years ago

I have tried several ways to make this work, but none seem to do the trick. Any help would be appreciated. Basically want to change the Player's default animations to different (roblox standard animation package options https://www.roblox.com/catalog/?Category=12&Subcategory=36&Direction=2) after touching a brick. NOT when they are added to the game, but instead while they are in the middle of playing the game

I have tried several variations on the code below, and all variations run without errors, and it appear to change the Players "Animate" object properly, but does not result in any change to the Player when he moves.

for example .. the standard roblox "Ninja" animation Ninja Animation Id's (https://www.roblox.com/catalog/658839027/Ninja-Animation-Package)

Simplest attempt, just changing the AnimationId

`

script.Parent.Touched:connect(function(hit)

local humanoid = hit.Parent:findFirstChild("Humanoid")

if (humanoid) then 


    local Run = 658830056 
    local Walk = 658831143 
    local Fall = 658831500 
    local Jump = 658832070 
    local Idle = 658832408 
    local Swim = 658832807 
    local Climb = 658833139


    local player = hit.Parent
    local anim = player.Animate


    --jut change the animation id
    local animation = anim:FindFirstChild("walk")
    animation.WalkAnim.AnimationId = 'http://www.roblox.com/asset/?id='..Walk


end

end)

`

Slightly different approach removing the original animation and creating a new one

`

script.Parent.Touched:connect(function(hit)

local humanoid = hit.Parent:findFirstChild("Humanoid")

if (humanoid) then 

    local Run = 658830056 
    local Walk = 658831143  
    local Fall = 658831500 
    local Jump = 658832070 
    local Idle = 658832408 
    local Swim = 658832807 
    local Climb = 658833139

    local player = hit.Parent
    local anim = player.Animate

    --remove old and add new walk animation
    local animation = anim:FindFirstChild("walk")

    local children = animation:GetChildren()
    for index, child in pairs(children) do
        child:Remove()
    end
    local newanim = Instance.new("Animation")
    newanim.Parent = animation
    newanim.Name = 'Anim'
    newanim.AnimationId = 'http://www.roblox.com/asset/?id='..Walk

end 

end)

`

Then it occurred to me maybe the resource needed to be loaded so I tried this:

`

script.Parent.Touched:connect(function(hit)

local humanoid = hit.Parent:findFirstChild("Humanoid")

if (humanoid) then 


    local Run = 658830056 
    local Walk = 658831143 
    local Fall = 658831500 
    local Jump = 658832070 
    local Idle = 658832408 
    local Swim = 658832807 
    local Climb = 658833139


    local player = hit.Parent
    local anim = player.Animate


    local asset = game.InsertService:LoadAsset(Walk):GetChildren()[1]
    local thisone = asset:FindFirstChild("walk")
    local clone = thisone:Clone()
    clone.Parent = anim


end

end)

`

and then i tried variations on all three ... They all did the same thing which was change the properties on Workspace."PLAYERNAME".Animate."ANIMATIONNAME" which is what I expected it to do ,but the changes did not result in the player actually following these new definitions, which is what has thrown me for a loop ... Any help would be appreciated.

0
maybe also worth noting I did also try stopping all running animations before changing/adding new animations using this snippet for _,v in pairs(humanoid:GetPlayingAnimationTracks()) do v:Stop(0) end gamingwDanny 0 — 6y
0
I kind of sped through this. Is changing the animation id of the already existing animation an option? Optikk 499 — 6y
0
thats the first i tried .. and it did change it in the properties, but seemed to not change the actual game play gamingwDanny 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I think I figured it out ... For anyone having issues changing default animations ... Make sure you really inspect what ID's roblox uses internally. The external ID's are not necessarily the internal ID's

0
yeah but what does that mean tho hermandise345 0 — 2y
0
how can you find out what ids are used internally? hermandise345 0 — 2y
Ad

Answer this question