Animation doesnt play after reset on mobile

Exactly what the title says

I have a taunt animation, it freezes player’s movement when played
When a player on PC presses G, it plays perfectly
But a player on mobile needs to press a button in order to play this taunt
First, it plays, but when i reset and click the button again my movement is freezed, but the animation doesnt play

I tried searching forum for the answers, but they dont seem to help me

local humanoid = game.Players.LocalPlayer.Character:WaitForChild('Humanoid'):WaitForChild('Animator')
local playing = false 
local anim = script:WaitForChild('Taunt')

local playAnim = humanoid:LoadAnimation(anim)
local sound = humanoid.Parent.Parent:WaitForChild('Sound')

local UIS = game:GetService("UserInputService")

script.Parent.MouseButton1Click:Connect(function()
		if playing == false then do
			playing = true
			print('playing')
			UIS.ModalEnabled = true  --freeze player


				sound:Play() 		--music n stuff
				playAnim:Play()	
			end
		else -- but if playing == true
		UIS.ModalEnabled = false --unfreeze
			playing = false
			playAnim:Stop()  
			sound:Stop()
		end


	
end)


game.Players.LocalPlayer.CharacterAdded:Connect(function()  --if player respawned variables reset
	local humanoid = game.Players.LocalPlayer.Character:WaitForChild('Humanoid'):WaitForChild('Animator')
	local playing = false 
	local anim = script:WaitForChild('Taunt')

	local playAnim = humanoid:LoadAnimation(anim)
	local sound = humanoid.Parent.Parent:WaitForChild('Sound')

end)

if you need PC/Console script i can send it

Thanks

I think the issue is that you are loading the animation into the humanoid, but not reloading it once the user dies. You could try either

A) Reloading the animation into the new humanoid every time the player resets (maybe using a Player.CharacterAdded event)

OR

B) Reloading the animation every time the user clicks and tries the taunt.

Let me know if you have any questions, and good luck.

I tried both of them already (A variant is the one i used in the message)
B variant works fine (thanks for that!) but now i cant stop the animation
is there any way to fix that?

The issue with your implementation of variant A is that you are setting the playAnim as a new local variable, so it doesn’t change the original one when being called. You could just remove the ‘local’ in front of it there to fix that.

oh wow, it worked
very very big thanks for the answer!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.