Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you find humanoid inside of a localscript?

I am trying to play an animation when a specific button is pressed, but I always fail to find the humanoid part of the character, making this impossible. Any suggestions?

2 answers

✓ Accepted answer

Use LocalPlayer.Character.Humanoid

More information here:https://developer.roblox.com/en-us/api-reference/property/Players/LocalPlayer

Local Script:

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):wait()
local Humanoid = LocalPlayer.Character.Humanoid

Server Script

game.Players.PlayerAdded:Connect(
    function(plr)
        plr.CharacterAdded:Connect(
            function(char)
            local humanoid = char.Humanoid
            end
        )
    end
)

1 comment

0

Thanks.

This is how you do it.

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character
repeat
	wait()
until Character:FindFirstChildOfClass("Humanoid")
local Humanoid = Character:FindFirstChildOfClass("Humanoid")

This discussion is preserved as it was. New answers, comments, and votes are closed.