Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i reference Humanoid?

Asked by 4 years ago

So i'm trying to reference the Humanoid so I can damage the player upon touching something, but it doesn't work. Here is how I tried to reference the Humanoid

1local humanoid = game.Players.LocalPlayer:FindFirstChild("Humanoid")

I also tried local humanoid = game.Players.LocalPlayer:WaitForChild("Humanoid") but didnt work

1 answer

Log in to vote
0
Answered by 4 years ago

Humanoid is a child of Character. So you will need to add another hierarchy in order to get the humanoid. Also I recommend putting CharacterAdded in case the character isn't there.

1local player = game.Players.LocalPlayer
2local character = player.Character or player.CharacterAdded:Wait()
3local humanoid = character:WaitForChild("Humanoid")
0
Thanks :D YandH015 9 — 4y
Ad

Answer this question