generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Attempt to index global player (a nil value)

Previous Thread :: Next Thread 
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
12 Apr 2015 05:41 PM
Output Error = Workspace.Message Script:6: attempt to index global 'Player' (a nil value)

Player = game.Players.LocalPlayer

local ScreenGui = Instance.new("ScreenGui", game.StarterGui)
local Frame = Instance.new("Frame", game.StarterGui.ScreenGui)
local TextLabel = Instance.new("TextLabel", game.StarterGui.ScreenGui.Frame)
ScreenGui.Parent = Player.PlayerGui
Frame.Size = UDim2.new(0,0,0,0)
TextLabel.Size = UDim2.new(0,1375,0,50)
Frame.Position = UDim2.new(0,0,0,0)
TextLabel.Position = UDim2.new(0,1,0,1)
TextLabel.TextColor3 = Color3.new(0/255, 0/255, 255/255)
TextLabel.BackgroundTransparency = 0.85
TextLabel.BackgroundColor3 = Color3.new(0/255, 0/255, 0/255)
TextLabel.Font = "ArialBold"
TextLabel.TextScaled = true

Sad For My Sad
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
12 Apr 2015 05:53 PM
repeat wait() until game.Players.LocalPlayer;

Also 0/255 :c
Report Abuse
CscLambda is not online. CscLambda
Joined: 09 Nov 2014
Total Posts: 46
12 Apr 2015 05:54 PM
....
TextLabel.TextColor3 = Color3.new(0, 0, 1)
TextLabel.BackgroundTransparency = 0.85
TextLabel.BackgroundColor3 = Color3.new(0, 0, 0)
....

FTFY
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
12 Apr 2015 06:01 PM
@e where do I put that. Why not just fix it.

Sad For My Sad
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 06:02 PM
LocalPlayer can't be indexed if you are using a server script.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
12 Apr 2015 06:04 PM
just like clone said, LocalPlayer can't be used in ServerScripts, and it couldn't error in a LocalScript, cos it is only Replicated to the Client (and Starts) when the Client itself Starts (Obviously) so then LocalPlayer could be used...

"My Life is going Good... but..."
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
12 Apr 2015 06:12 PM
Localscripts don't create instances though.

Sad For My Sad
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
12 Apr 2015 06:13 PM
what u mean?
'Localscripts don't create instances though'

"My Life is going Good... but..."
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 06:15 PM
LocalScripts can make instances just fine.
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
12 Apr 2015 06:16 PM
Someone last night told me that. So where do I place the localscript, and what goes with what

Sad For My Sad
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
12 Apr 2015 06:19 PM
What's wrong with this then?

game.Players.PlayerAdded:connect(function(player)
if game.Players.NumPlayers < 2 then
game.Workspace.GameScript.Disabled = true
game.player.PlayerGui.ScreenGui.Frame.TextLabel.Text = "Hello, "..player.Name.. ", welcome to Laser Tag 0.3.0, unfortunately, this game has a limit for players, so please invite a friend!"
elseif game.Players.NumPlayers >= 2 then
game.player.PlayerGui.ScreenGui.Frame.TextLabel.Text = "There are now 2 players, rounds are starting soon!"
wait(5)
game.Workspace.GameScript.Disabled = false
game.StarterGui.ScreenGui:Destroy()
end
end)

Sad For My Sad
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 06:20 PM
Instead of having the server change the gui, have a StringValue called InfoReel or something, and have a localscript in the client which reflects what the value of the InfoReel is.
Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
12 Apr 2015 06:22 PM
^

Aha! I knew it wasn't a bad idea.
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
12 Apr 2015 06:22 PM
How do I do that. I never work with values. *Face-Palm*

Sad For My Sad
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 06:23 PM
local h = workspace:WaitForChild("InfoReel")

function updateGui()
script.Parent.TextLabel.Text = h.Value
end

updateGui()
h.Changed:connect(updateGui)
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
12 Apr 2015 06:23 PM
And also, what localscript, what is in it, how do I put it in client, what are you talking about.

Sad For My Sad
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 06:24 PM
Instead of having the script create the gui, just have it premade in the StarterGui. I don't even know why you are making it with scripts to begin with.

Insert a LocalScript into the Frame, and paste the script I just posted above.
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
12 Apr 2015 06:28 PM
How do I still get the ..player.Name.. then?

Sad For My Sad
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 06:29 PM
If its in a LocalScript, you can use game.Players.LocalPlayer.Name
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
12 Apr 2015 06:32 PM
Where do I put that.

Sad For My Sad
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
12 Apr 2015 06:33 PM
What do I put in the value?

Sad For My Sad
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 06:34 PM
Oh wait, now I see.
Here's a neat trick you can do.

Make it so the game sets the message to something like "Hello PLAYERNAME!"

Then use this line instead

script.Parent.TextLabel.Text = string.gsub(h.Value,"PLAYERNAME",game.Players.LocalPlayer.Name)
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 06:35 PM
@Surface
Whatever you want. It acts as a global message system.
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
12 Apr 2015 06:36 PM
I put it in workspace, and it says h is unknown.

Sad For My Sad
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 06:37 PM
h = workspace:WaitForChild("InfoReel")

Add that to the top of the script :P
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image