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 3 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

local 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 3 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.

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

Answer this question