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

Character is nil value, pls help?

I have a script that tells you what the character is. But it says the character is a nil value. I think its because im using the script before the character is made but i dont know how to fix that.

3 comments

0

Put the script in the message with codebox.

0

Sorry, but scripting helpers community are not Vangas. If you want to fix your problem, put your script into script blocks and then post them

0

ok i sent the part where my script is broken

2 answers

✓ Accepted answer

Remember to use LocalScript

you can use CharacterAdded:Wait() (this wait for character added.)

example:

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait() -- Wait for character added

You can try this:

local player = game.Players.LocalPlayer
local playergui = player:WaitForChild("PlayerGui") -- wait for player gui, for no errors
local char = player.Character or player.CharacterAdded:Wait()

Wiki pages:

CharacterAdded

WaitForChild

do not use variable = value use local variable = value

Hope it helped :)

1 comment

0

Repeating until an object exists is not the way to go

this is the part where i got stuck

player = game.Players.LocalPlayer
playergui = player.PlayerGui
char = player.Character

how would i go about on fixing this because it ends up saying character is nil

1 comment

0

char = player.Character or player.CharacterAdded:Wait()

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