Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 19 Apr 2016 11:53 AM |
| Hi! I tried to create a button that beginns your tycoon (using ClickDetector). The only problem was - I don't know how do I check player's name in global script. |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
| |
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
| |
|
|
| 19 Apr 2016 12:34 PM |
| Iirc, the player name is not necessarily unique, so using player ID is better. |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 19 Apr 2016 12:50 PM |
| What about guests? And how to check this ID with a global script? |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2016 01:04 PM |
this might work or it might not work ok
clickdetector.Clicked:connect(function(player) game.Players[player].UserId end)
#Code print("Narwhals are our future") |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 19 Apr 2016 01:09 PM |
It says game.Players[player].UserId is a bad argument. Have you got any other ideas? |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2016 01:12 PM |
mouse click with userinput service and mouse target check
and then fire server and let server handle tycoon
#Code print("Narwhals are our future") |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2016 01:13 PM |
| Guests also have userids, just special negative ones. |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 19 Apr 2016 01:13 PM |
What i got for now is local button = script.Parent.Parent; button.Click.MouseClick:connect(function(player) print(player:FindFirstChild("Humanoid").Name) end) but it says 'attempt to index a nil value' |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 19 Apr 2016 01:14 PM |
if your game isnt fe then this is fine.
game.Players.PlayerAdded:connect(function(player) print(player.Name) end)
|
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 19 Apr 2016 01:15 PM |
Ok, seems good, but how do I check target? And what I was thinking about is how do I 'transport' a variable (here player's name/id) from LocalScript to ServerScript. |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 19 Apr 2016 01:17 PM |
| Yeah, but it says only name of player that joins the game. What i want is checking player's name/id who actually clicked a button. |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 19 Apr 2016 01:18 PM |
Well, now I see how dumb i was. Everything i needed to do is:
local button = script.Parent.Parent; button.Click.MouseClick:connect(function(player) print(player.Name) end)
Thanks for your help anyway. |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2016 01:19 PM |
very roughly,
local m = p:GetMouse()
--userinputservice to check mouse click
if m.Target == [tycoon button] then
remotevent:FireServer(target)
in server:
remoteevent.OnServerEvent:connect(function(player,target) --intitiate tycoon end)
#Code print("Narwhals are our future") |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 19 Apr 2016 01:36 PM |
Well, I think it's even better (I get a lot of errors now :D) My (propably) last question is - can I check string value from model in workspace with local script? |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 19 Apr 2016 01:38 PM |
And I think I need to add something to the script, but I don't really know what :/ I mean this script:
if m.Target == [tycoon button] then
remotevent:FireServer(target)
What object and function should it be in? |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 19 Apr 2016 01:41 PM |
The problemin my script is: It says there's no 'Tycoon' in my player, while it is there (game.Workspace.player1)
local button = script.Parent.Parent; button.Click.MouseClick:connect(function(player) local pl = player; if pl.Tycoon == 'None' and button.Parent.Parent.Owner == 'None' then button.Parent.Parent.Owner.Valuer = pl.Name; pl.Tycoon.Value = button.Parent.Parent.Name; end end) |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 19 Apr 2016 01:47 PM |
| Sorry, I didn't say what 'Tycoon' is - it's a string value (default set on 'None') |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 06:23 AM |
Nvm, if found what i need to do. If anyone needs it it's here:
local button = script.Parent.Parent; button.Click.MouseClick:connect(function(player) local pl = game.Workspace[player.Name]; if pl.Tycoon.Value == 'None' and button.Parent.Parent.Owner.Value == 'None' then script.Parent.Parent.Material = 'Neon'; button.Parent.Parent.Owner.Value = pl.Name; pl.Tycoon.Value = button.Parent.Parent.Name; end end) |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 06:24 AM |
Sry mistake Nvm, I found what I...* |
|
|
| Report Abuse |
|
|