Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Character is nil value, pls help?

Asked by 5 years ago

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.

0
Put the script in the message with codebox. yHasteeD 1819 — 5y
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 HaveASip 494 — 5y
0
ok i sent the part where my script is broken Metraria 17 — 5y

2 answers

Log in to vote
1
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

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 :)

0
Repeating until an object exists is not the way to go User#24403 69 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

0
char = player.Character or player.CharacterAdded:Wait() HaveASip 494 — 5y

Answer this question