#how to define humanoid
11 messages · Page 1 of 1 (latest)
If you're in a LocalScript, you can just use Players.LocalPlayer and then get the character setting a variable to Player.Character or Player.CharacterAdded:Wait() which waits for the Player.CharacterAdded event to fire in case the character hasn't loaded yet, then just use :WaitForChild("Humanoid")
Yeah that should work if the script runs after the character is loaded
I personally do it like this
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid") :: Humanoid -- the ":: Humanoid" is type-casting the variable to the Humanoid type, allowing for auto-completion
print(`{Player.Name}'s max health is {Humanoid.MaxHealth}`)
Double equal sign is comparassion
hum.MaxHealth == 150 is an expression, which returns a boolean
Yes, 1 equal sign will make it a statement instead
You're Polish?
Hacks
(the file name you sent is in Polish)
Yeah, assuming all the variables aren't nil and are the correct type