So my current script just throws error at me when I’'m trying to get a humanoid via local player. The error is attempt to index nil with ‘Humanoid’. Are there any variants how to solve avoid that happening?
local player = game.Players.LocalPlayer
local hum = player.Character.Humanoid
mouse.Button1Down:Connect(function()
if hum.Health < hum.MaxHealth then
hum.Health = hum.MaxHealth
The Humanoid instance is not created yet when you try to get it, just wait for it until is placed, something like this:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
warn(hum)