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: Small problem

Previous Thread :: Next Thread 
Opisek is not online. 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 is not online. Opisek
Joined: 05 Aug 2014
Total Posts: 155
19 Apr 2016 12:05 PM
Bump
Report Abuse
Opisek is not online. Opisek
Joined: 05 Aug 2014
Total Posts: 155
19 Apr 2016 12:26 PM
Can anyone help me?
Report Abuse
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
19 Apr 2016 12:34 PM
Iirc, the player name is not necessarily unique, so using player ID is better.
Report Abuse
Opisek is not online. 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
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
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 is not online. 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
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
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
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
19 Apr 2016 01:13 PM
Guests also have userids, just special negative ones.
Report Abuse
Opisek is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. Opisek
Joined: 05 Aug 2014
Total Posts: 155
20 Apr 2016 06:24 AM
Sry mistake
Nvm, I found what I...*
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