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.
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