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?
✓ ANSWER ACCEPTED
How do you find humanoid inside of a localscript?
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
)
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.

1 comment
Thanks.