Hi, i recently made a script but it's not playing the animation on my character.
local Player = game.Players.LocalPlayer; local AnimId = (248335946); local URL = ("http://www.roblox.com/asset/?id=248335946"); local Anim = (URL..tostring(AnimId)); Player.CharacterAdded:connect(function(Char) local Hum = Char:WaitForChild("Humanoid"); local Track = Hum:LoadAnimation(Anim) Track:Play(); return nil; end);
Simple fix, you're concatanating the URL string that already has an asset Id with another asset Id, creating an invalid animation asset. Another thing is, while loading animations this way, we actually need the physical animation object to load. So we can just create with with Instance.new:
local Player = game.Players.LocalPlayer; -- Got rid of the AnimId entirely local Anim = "http://www.roblox.com/asset/?id=248335946" -- Already valid Player.CharacterAdded:connect(function(Char) local Hum = Char:WaitForChild("Humanoid") local AnimObj = Instance.new("Animation",Hum) AnimObj.AnimationId = Anim local Track = Hum:LoadAnimation(AnimObj ) Track:Play() AnimObj:Destroy() -- We also don't need that return value end)
Or ...
local Player = game.Players.LocalPlayer local AnimId = 248335946 local URL = "http://www.roblox.com/asset/?id=" -- Got rid of the Id here local Anim = URL..tostring(AnimId) Player.CharacterAdded:connect(function(Char) local Hum = Char:WaitForChild("Humanoid") local AnimObj = Instance.new("Animation",Hum) AnimObj.AnimationId = Anim local Track = Hum:LoadAnimation(AnimObj) Track:Play() AnimObj:Destroy() end)