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;
local Anim = "http://www.roblox.com/asset/?id=248335946"
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)
Or ...
local Player = game.Players.LocalPlayer
local AnimId = 248335946
local URL = "http://www.roblox.com/asset/?id="
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)
4 comments
Still dosen't work. :(
Oops, I forgot loading animations requires using the Animation object. I'll revise my answer.
Concatenation can be done without tostring (as the compiler converts automatically), and it can also be done directly. But, your choice, i guess.
With numbers, yes. But the concatenation process can only be preformed on the number as a variable, not a direct value. However, the same rules don't apply for other arbitrary values.