Playing A Humanoid Animation After Click

Hey, so I’ve been struggling a lot recently with trying to code a script that would play an animation within a seperate humanoid model after the player clicks a part. Is there a way to do this?

yeah use a clickdetector mouseclick event to detect a click on the part then get the specified humanoid model stored in a local variable then load the animation and play it

1 Like

try structuring it like this:

local clickDetector = script.Parent
local charModel=game.Workspace["Modelchar"] --This is the separate humanoid model. change it to yours!
local humanoid = charModel:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local Animation = Instance.new("Animation") --get your animation instead and its correct id!
Animation.AnimationId = "rbxassetid://2515090838" 
local AnimationTrack = animator:LoadAnimation(Animation)
clickDetector.MouseClick:Connect(function(player)
	AnimationTrack:Play()
end)
1 Like

Thank you so much! you do not know the amount of work this saved me

glad it was helpful for you and quick