hello robloxians,
i just made script for game and the animation cant load, anyone can tell me how can i fix that?
here is the script:
script.Parent.ClickDetector.MouseClick:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
hit.Parent.Humanoid:LoadAnimation(script.Animation)
end)
thanks for help,
REALINONOOBYT.
2 Likes
ClickDetector returns the player who clicked on the button. Change it to hit.Character.Humanoid and it should work.
2 Likes
script.Parent.ClickDetector.MouseClick:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
hit.Character.Humanoid:LoadAnimation("rbxassetid://5004011446")
end)
When loading an animation, you pass in the AnimationTrack object, not the asset id.
Refer to this for more information: Humanoid | Documentation - Roblox Creator Hub
2 Likes