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

How can i reference Humanoid?

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

✓ Accepted answer

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")

1 comment

0

Thanks :D

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