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: Problem with PlayerName script

Previous Thread :: Next Thread 
Risentheim is not online. Risentheim
Joined: 26 Sep 2014
Total Posts: 240
20 Mar 2015 04:48 PM
(Yes, I probably have an horrible syntax.)
Here's the script:

script.Parent.MouseButton1Click:connect(function(player)
script.Parent.Visible = false
script.Parent.Parent.playerlabel.Text = player.Name
stime = 600
for i=1,600 do
stime = stime - 1
script.Parent.Parent.timelabel.Text = stime
wait(1)
end
stime = 600
script.Parent.Visible = true
script.Parent.Parent.playerlabel = "No Player"
end)

Here's the error:
17:41:02.424 - Workspace.final.Screen.cOS.desktop.shift.shift.Script:3: attempt to index local 'player' (a nil value)

AFAIK function(player) should set the "player" variable to the player object, but in this case, it doesn't work. Or I am doing something wrong.


~ I see you, you see me. ~
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
20 Mar 2015 04:49 PM
script.Parent.MouseButton1Click:connect(function(player)

That doesnt return the player


local player=game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
Report Abuse
Risentheim is not online. Risentheim
Joined: 26 Sep 2014
Total Posts: 240
20 Mar 2015 05:22 PM
Yeah, but it's a surfacegui, so no local scripts.


~ I see you, you see me. ~
Report Abuse
Risentheim is not online. Risentheim
Joined: 26 Sep 2014
Total Posts: 240
20 Mar 2015 05:28 PM
Seriously, I need help with this.
I need to get the player's name.
Google only shows scripts for bricks and not GUIs.


~ I see you, you see me. ~
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
20 Mar 2015 05:29 PM
who said you couldnt use localscripts with surfaceguis
Report Abuse
T00NAMI is not online. T00NAMI
Joined: 10 Mar 2013
Total Posts: 211
20 Mar 2015 05:29 PM
Maybe use a click detector to select the player who clicked and have the gui detect that click. Just a theory, I have not tried it.
Report Abuse
Risentheim is not online. Risentheim
Joined: 26 Sep 2014
Total Posts: 240
20 Mar 2015 05:29 PM
@above

Tried it and didn't worked.


~ I see you, you see me. ~
Report Abuse
Risentheim is not online. Risentheim
Joined: 26 Sep 2014
Total Posts: 240
20 Mar 2015 05:30 PM
@above = @Abstract


~ I see you, you see me. ~
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
20 Mar 2015 05:30 PM
did you put it inside of startergui and set the adornee?
Report Abuse
Risentheim is not online. Risentheim
Joined: 26 Sep 2014
Total Posts: 240
20 Mar 2015 05:31 PM
Why would I put a surfacegui into the StarterGui?


~ I see you, you see me. ~
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
20 Mar 2015 05:36 PM
So you can do this with LocalScripts.

http://gyazo.com/d3a470007cc68ccff0231d503c5d49c9

What I used:

SurfaceGui
-TextLabel
--Script

Script:

local sgui = script.Parent.Parent

sgui.Adornee = workspace.Part

script.Parent.Text = ("Hi, "..game.Players.LocalPlayer.Name)
Report Abuse
Lecturous is not online. Lecturous
Joined: 17 Aug 2013
Total Posts: 1096
20 Mar 2015 05:40 PM
"No local scripts"
That is why we have RemoteFunctions and RemoteEvents. In a local script, set a RemoteFunction to this:

function script.Parent.OnClientInvoke()
return game.Players.LocalPlayer
end

In your script the player can be this:
plr = game.Workspace.RemoteFunction:InvokeClient()

/: If I give you a script on the forums with no indenting, then idk if it works. :\
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
20 Mar 2015 05:41 PM
Orrrr you could just do what I said and put the SurfaceGUI in StarterGui
Report Abuse
Risentheim is not online. Risentheim
Joined: 26 Sep 2014
Total Posts: 240
20 Mar 2015 05:43 PM
I changed the script to localscript.
Now, the script won't even execute.
This is my script:

function yo()
print("hey")
script.Parent.Visible = false
script.Parent.Parent.playerlabel.Text = game.Players.LocalPlayer.Name
stime = 600
for i=1,600 do
stime = stime - 1
script.Parent.Parent.timelabel.Text = stime
wait(1)
end
stime = 600
script.Parent.Visible = true
script.Parent.Parent.playerlabel = "No Player"
end

script.Parent.MouseButton1Click:connect(yo)

The script just doesn't execute.
There's no error logs. It doesn't even print the hey.


~ I see you, you see me. ~
Report Abuse
Risentheim is not online. Risentheim
Joined: 26 Sep 2014
Total Posts: 240
20 Mar 2015 05:44 PM
Take note that what will happen on the brick needs to be shown to everyone, so I guess no localscripts.


~ I see you, you see me. ~
Report Abuse
Risentheim is not online. Risentheim
Joined: 26 Sep 2014
Total Posts: 240
20 Mar 2015 06:01 PM
Is it this hard?
I just need to grab the player's name who pressed the button.
The methods with Remotefunctions didn't worked.


~ I see you, you see me. ~
Report Abuse
LuaLlama is not online. LuaLlama
Joined: 25 Jan 2014
Total Posts: 1123
20 Mar 2015 06:20 PM
Take a wander through ROBLOX's APIs, I bet you will find one.
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