|
| 21 May 2014 04:24 PM |
If the script isn't in the startergui? Trying to get all my scripts to work in ServerScriptService. |
|
|
| Report Abuse |
|
|
youssef04
|
  |
| Joined: 22 Jan 2011 |
| Total Posts: 1745 |
|
|
| 21 May 2014 04:27 PM |
function click(p) --stuff with p, for example: p:Kick() PATH_TO_GUI.MouseButton1Down:connect(click) |
|
|
| Report Abuse |
|
|
|
| 21 May 2014 04:29 PM |
| @youssef lol no. that doesn't work. |
|
|
| Report Abuse |
|
|
|
| 21 May 2014 04:30 PM |
| @Teh, can you tell me how? |
|
|
| Report Abuse |
|
|
|
| 21 May 2014 04:30 PM |
If it's a surface gui, you have to put the gui inside StarterGui and set it's Adornee to the part, if it's a regular gui, you can just use a variable with enough parents to get to player, or this.
script.Parent.Button1Down:connect(function() --I think its MouseButton1Down local player = script.Parent repeat wait() player = player.Parent until player:FindFirstChild("PlayerGui")
--things --player is the player now
end) |
|
|
| Report Abuse |
|
|
|
| 21 May 2014 04:33 PM |
@Sens
I asked how to do it without the script being in the startergui itself... |
|
|
| Report Abuse |
|
|
NeonKitty
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 87 |
|
|
| 21 May 2014 04:33 PM |
just do
player = script.Parent.Parent.Parent ... (however many parents until you get to the player)
this works because the gui will be located in PlayerGui. |
|
|
| Report Abuse |
|
|
|
| 21 May 2014 04:34 PM |
Well if you use PlayerAdded event, then it's easy!
game.Players.PlayerAdded:connect(function(plr) plr:WaitForChild("PlayerGui") plr.PlayerGui.ScreenGui.Frame.TextButton.Button1Down:connect(function()
--stuff
end) end) |
|
|
| Report Abuse |
|
|
|
| 21 May 2014 04:36 PM |
NO.
THE SCRIPT THAT WORKS THE GUI IS IN ServerScriptService. HOW DO I DETECT THE PLAYER THAT CLICKED THE GUI IF I CAN'T DO SCRIPT.PARENT.PARENT.PARENT (etc.) |
|
|
| Report Abuse |
|
|
|
| 21 May 2014 04:37 PM |
| Well I just answered it, PlayerAdded is the main way, other than that, it would require other ways which would be more complicated. |
|
|
| Report Abuse |
|
|
|
| 21 May 2014 04:38 PM |
| Wouldn't PlayerAdded stop working if you died? |
|
|
| Report Abuse |
|
|
|
| 21 May 2014 04:39 PM |
| Nope! It stops working when you leave. |
|
|
| Report Abuse |
|
|
|
| 21 May 2014 05:00 PM |
Sorry for the late response.
gui buttons' event, MouseButton1Down, doesn't return the player, the only way to do it is, in a local script, have a function that fires the player's name to the remote event, and let a server script pick it up and use that name.
This is how it's done:
http://www.roblox.com/Developer-Product-Sample-place?id=147965737 |
|
|
| Report Abuse |
|
|