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
1 | local humanoid = game.Players.LocalPlayer:FindFirstChild( "Humanoid" ) |
I also tried local humanoid = game.Players.LocalPlayer:WaitForChild("Humanoid")
but didnt work
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.
1 | local player = game.Players.LocalPlayer |
2 | local character = player.Character or player.CharacterAdded:Wait() |
3 | local humanoid = character:WaitForChild( "Humanoid" ) |