How can I get the player's humanoid from a server script?

Pretty self explanatory. Here is my script, I want to get the humanoid to load the animations but I dont know how to. This script is in ServerScriptStorage

local MyRoot
local re = game:GetService("ReplicatedStorage")


--Variables
local Event
local state = nil
local idleAnim1
local idleAnim2
players = game:GetService("Players")


-- Animations
local idle = re:WaitForChild("Assets").Animations.Idle
local walk = re:WaitForChild("Assets").Animations.Walk
local berserkWalk = re:WaitForChild("Assets").Animations.WalkBerserk
local berserkIdle = re:WaitForChild("Assets").Animations.IdleBerserk
berserkWalk = humanoid:LoadAnimation(berserkWalk)
berserkIdle = humanoid:LoadAnimation(berserkIdle)
-- Check for movement
Event = humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	local magnitude = humanoid.MoveDirection.Magnitude

	idleAnim1 = humanoid:LoadAnimation(idle)
	if magnitude <= 0.1 and state ~= "idle" then
		state = "idle"

		if humanoid.Parent.Name == "BerserkMorph" then

			berserkIdle:Play()

		else
			idleAnim1:Play()

		end


		if idleAnim2 then

			idleAnim2:Stop() 
		end



		if berserkWalk then
			berserkWalk:Stop()
		end

	elseif state ~= "other" then
		state = "other"


		idleAnim2 = humanoid:LoadAnimation(walk)

		if player.Character.Name == "BerserkMorph" then
			berserkWalk:Play()

		else

			idleAnim2:Play()

		end



		if idleAnim1 then
			idleAnim1:Stop()

			if berserkIdle then
				berserkIdle:Stop()
			end



		end

	end

end)





I was kinda confused by this post but my understanding was that you weren’t able to locate the players humanoid. If that is the case, then here are two solutions:
Player.Character.Humanoid or Player.Character:FindFIrstChild(“Humanoid”)

1 Like

it should be done in a localscript

-- localscript inside startcharacterscripts
local character = sctipt.Parent
local animator = character.Humanoid.Animator
local animationTrack = animator:LoadAnimation(game.ReplicatedStorageAnimations.WalkBerserk)
animationTrack:Play()

here is some info on how to change default animations

1 Like