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

why is the character variable a nil value?

local uis = game:GetService("UserInputService")
local anim = Instance.new("Animation")
local p = game.Players.LocalPlayer
local c = p.Character
local h = c:WaitForChild("Humanoid")
if h then
	print("H")
end

it doesn't print in the output h but it says that c is a nil value how can i solve this?

1 answer

✓ Accepted answer
local c = p.Character or p.CharacterAdded:Wait()

local c = p.Character returned nil because character wasnt loaded, if you add or p.CharacterAdded:Wait() then if p.Character returns nil it will wait til character loads

2 comments

0

thank you!

0

welcome

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