|
| 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 |
|
|
|
| 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 |
|
|
|
| 20 Mar 2015 05:22 PM |
Yeah, but it's a surfacegui, so no local scripts.
~ I see you, you see me. ~ |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 20 Mar 2015 05:29 PM |
| who said you couldnt use localscripts with surfaceguis |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 20 Mar 2015 05:29 PM |
@above
Tried it and didn't worked.
~ I see you, you see me. ~ |
|
|
| Report Abuse |
|
|
|
| 20 Mar 2015 05:30 PM |
@above = @Abstract
~ I see you, you see me. ~ |
|
|
| Report Abuse |
|
|
|
| 20 Mar 2015 05:30 PM |
| did you put it inside of startergui and set the adornee? |
|
|
| Report Abuse |
|
|
|
| 20 Mar 2015 05:31 PM |
Why would I put a surfacegui into the StarterGui?
~ I see you, you see me. ~ |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 20 Mar 2015 05:41 PM |
| Orrrr you could just do what I said and put the SurfaceGUI in StarterGui |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|