"Attempt to index local 'char'(a nil value)" Error?
Whenever I test this script in Roblox Studio, it works fine. But when I open the client log in the developer console on the actual game, I get this error -
player.secretboy6.PlayerGui.LocalScript:3: attempt to index local 'char' (a nil value)
-and the script fails to work. How do I fix this?
01 | local player = game.Players.LocalPlayer |
02 | local char = player.Character |
03 | local torso = char:WaitForChild( "Torso" ) |
06 | Pos = Instance.new( "Folder" ,script.Parent.Parent) |
09 | XPos = Instance.new( "IntValue" ,Pos) |
12 | YPos = Instance.new( "IntValue" ,Pos) |
15 | ZPos = Instance.new( "IntValue" ,Pos) |
30 | local X = script.Parent.Parent.Position.XPos.Value |
31 | local Y = script.Parent.Parent.Position.YPos.Value |
32 | local Z = script.Parent.Parent.Position.ZPos.Value |
34 | if a = = nil or a = = true then |
35 | if X > = - 5 and X < = 5 then |
36 | if Y > = 2 and Y< = 10 then |
37 | if Z > = 190 and Z < = 202 then |
39 | script.Parent.Parent.PlayerGui.ScreenGui.PressFTo.TextTransparency = i |
43 | script.Parent.ScreenGui.chatFrame.FirstConversation.Disabled = false |
50 | if not (X > = - 5 and X < = 5 ) or not (Z > = 190 and Z < = 202 ) then |
52 | script.Parent.Parent.PlayerGui.ScreenGui.PressFTo.TextTransparency = i |
56 | script.Parent.ScreenGui.chatFrame.FirstConversation.Disabled = true |
62 | XPos.Changed:connect(Jay) |
63 | YPos.Changed:connect(Jay) |
64 | ZPos.Changed:connect(Jay) |