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

Why does this give me an error??

Asked by 9 years ago

Luckily, the output says Line 3, so I don't have to put all 125 lines of code. But this error makes no sense. The whole script is in a LocalScript.

Works in Play solo, but not in Online...

Character = game.Players.LocalPlayer.Character
wait(5)
Torso = Character.Torso --Aparently, the error is here...
mode = Instance.new("Model")
mode.Name = "Raggy"
mode.Parent = game.Workspace
face = 145952218

Output: attempt to index global 'Character' (a nil value)

2 answers

Log in to vote
1
Answered by
RedCombee 585 Moderation Voter
9 years ago

Just to be sure, you can try:

player = game.Players.LocalPlayer
repeat wait() until player.Character
character = player.Character
0
Hopefully, this will work. If it doesn't, there may be something wrong with your game. RedCombee 585 — 9y
Ad
Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

You define character before the character is loaded, thus making it equal nil. To fix this, simply delay the code until the character is loaded.

local plr = game.Players.LocalPlayer
    repeat wait() until plr.Character
local chr = plr.Character

Answer this question