Animation plays strangely

When a player goes insane, this animation plays. (ignore the glitched out arms, im gonna fix that problem later, but you can defintely see the difference.)


I have no idea how to fix this or what is causing it. this is my script

local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local UPS = RS.UpdatePlayerSanity

local sanity = script.Parent.Sanity

RS.TeamSelect.OnServerEvent:Connect(function(player, team)
	wait(.1)
	if player == Players:GetPlayerFromCharacter(script.Parent) then
		--print(true)
		while sanity.Value >= 0 do
			UPS:FireAllClients(Players:GetPlayerFromCharacter(script.Parent), sanity)
			wait(0.0001) --28.8
			sanity.Value -= 1
			if sanity.Value == 0 then
				script.Parent.HumanoidRootPart.Anchored = true
				for i,v in pairs(script.Parent.Humanoid:GetPlayingAnimationTracks()) do
					v:Stop()
				end
				local animation = game:GetService("ServerStorage").InsanityAnimation
				local loadanimation = script.Parent.Humanoid.Animator:LoadAnimation(animation)
				loadanimation:Play()
			end
		end
	else
		--print(false)
	end
end)

Also if a player is walking beforehand, the walking legs play with the animation.

try adding:

loadanimation.Priority = Enum.AnimationPriority.Action4

code:

local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local UPS = RS.UpdatePlayerSanity

local sanity = script.Parent.Sanity

RS.TeamSelect.OnServerEvent:Connect(function(player, team)
	wait(.1)
	if player == Players:GetPlayerFromCharacter(script.Parent) then
		--print(true)
		while sanity.Value >= 0 do
			UPS:FireAllClients(Players:GetPlayerFromCharacter(script.Parent), sanity)
			wait(0.0001) --28.8
			sanity.Value -= 1
			if sanity.Value == 0 then
				script.Parent.HumanoidRootPart.Anchored = true
				for i,v in pairs(script.Parent.Humanoid:GetPlayingAnimationTracks()) do
					v:Stop()
				end
				local animation = game:GetService("ServerStorage").InsanityAnimation
				local loadanimation = script.Parent.Humanoid.Animator:LoadAnimation(animation)
				loadanimation.Priority = Enum.AnimationPriority.Action4
				loadanimation:Play()
			end
		end
	else
		--print(false)
	end
end)
1 Like

Thanks!!!

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