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: LocalPlayer alternative

Previous Thread :: Next Thread 
Neztore is not online. Neztore
Joined: 10 Aug 2014
Total Posts: 56
15 Dec 2016 01:42 PM
Hello! I was wondering if I could get some help with this,
I have created a GUI that pops up when a certain brick is clicked.
Problem is, In order to make the GUI appear, I need to change it's .Visible to true.

As the script inside the brick is NOT a local script, I cannot use localplayer to access the GUI. (In player.LocalPlayer.PlayerGui)

Here's what I've currently got:
game.Players.LocalPlayer.PlayerGui.ShopGUI.MainFrame.Visible = true
and that of course, doesn't work.


So, what I'm really asking is if there's anyway to access the player that clicked the brick without using LocalPlayer.

Anyone got any ideas?
Thanks!
Report Abuse
kaddad14 is not online. kaddad14
Joined: 13 Apr 2013
Total Posts: 649
15 Dec 2016 01:44 PM
Well, since the player is clicking the brick, you could have it so that if the player clicks on something named the bricks name, then the gui turns visible.
Report Abuse
Neztore is not online. Neztore
Joined: 10 Aug 2014
Total Posts: 56
15 Dec 2016 01:45 PM
Elaborate please, I don't understand what you just said.
Report Abuse
llaserx is online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
15 Dec 2016 01:45 PM
http://wiki.roblox.com/index.php?title=API:Class/ClickDetector/MouseClick
Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
15 Dec 2016 01:46 PM
Put a remote event in replicated storage. Reference it both the server and local script. Put your LocalScript in the starter GUI and fire an event from the server script when it is clicked through the remote event in replicated storage. The LocalScript will receive it and make the GUI appear on the screen
Report Abuse
Neztore is not online. Neztore
Joined: 10 Aug 2014
Total Posts: 56
15 Dec 2016 01:47 PM
Thanks! I'll get to work trying to implement this.




Thank you again for your speedy reply.
Report Abuse
kaddad14 is not online. kaddad14
Joined: 13 Apr 2013
Total Posts: 649
15 Dec 2016 01:47 PM
Whenever the player clicks on a part called ("PART NAME") the gui turns visible. It's a work around from what you have. You have the player interact with the brick and then the brick interacting with the player. The way I'm suggesting is have the player check to see if they are interacting with the brick.
Report Abuse
llaserx is online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
15 Dec 2016 01:48 PM
Dont do ehat kri said

Look at my link
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
15 Dec 2016 01:49 PM
If the script is in the StarterGui, it should be a LocalScript.
You shouldn't be trying to find alternatives.


Report Abuse
kaddad14 is not online. kaddad14
Joined: 13 Apr 2013
Total Posts: 649
15 Dec 2016 01:49 PM
It's fine if you want to do his way. His way is better for like 1 or 2 buttons. But the way I was suggesting could handle a huge amount of buttons.
Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
15 Dec 2016 01:50 PM
@llaserx My way is the only way I found that actually works... If you have a better way then atleast share it.
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
15 Dec 2016 01:50 PM
local player = game.Players.LocalPlayer
local mouse = Player:GetMouse()

local buttons = frame:GetChildren() -- make a frame for all your buttons

for _,button in next,buttons do
button.MouseButton1Click:connect(function()
button.Visible = not button.Visible
end)
end


Report Abuse
llaserx is online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
15 Dec 2016 01:52 PM
http://wiki.roblox.com/index.php?title=API:Class/ClickDetector/MouseClick
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
15 Dec 2016 01:53 PM
Llaser I didn't read the other replies, but I'm 99.99% sure we're dealing with guis here.


Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
15 Dec 2016 01:54 PM
Yes even he can do that but that's not going to be able to bring the GUI on screen not since it requires a local script
Report Abuse
llaserx is online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
15 Dec 2016 01:54 PM
As the script inside the brick is NOT a local script, I cannot use localplayer to access the GUI. (In player.LocalPlayer.PlayerGui)
Report Abuse
Neztore is not online. Neztore
Joined: 10 Aug 2014
Total Posts: 56
15 Dec 2016 01:59 PM
I am using a NORMAL script inside a part to open a GUI stored inside the player.
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
15 Dec 2016 02:01 PM
for Pepe's sake just use your mouse instead of clickdetectors


local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

Clickables = {}

-- populate your table of clickables, add more as you do
for _,v in next,workspace.Buttons:GetChildren() do
table.insert(Clickables,v)
end

function ScanTable(val)
for _,v in next,Clickables do
if val == v then
return true
end
end
end

function Conditions(obj)
if obj and obj:IsA("BasePart") then -- add more conditionals with "and", such as distance, part name, etc...
return true
else return false
end
end

mouse.Button1Click:connect(function()
if mouse.Target and ScanTable(mouse.Target) and OtherConditions(mouse.Target) then
--make your GUI visible here, can pull data that's stored in the part you click
end
end)


Report Abuse
enzotinman1 is not online. enzotinman1
Joined: 22 Jun 2012
Total Posts: 408
15 Dec 2016 02:01 PM
What's better, doing what kaddad14 said and checking for the click in the player or checking for the click in a script in workspace?
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
15 Dec 2016 02:02 PM
fucntion Conditions
should be called
function OtherConditions
or vice versa


Report Abuse
Network_Replicated is not online. Network_Replicated
Joined: 22 Dec 2010
Total Posts: 406
15 Dec 2016 02:07 PM
are you people dumb
> use a localscript
Report Abuse
llaserx is online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
15 Dec 2016 02:08 PM
Mouseclick legit has an argument that allows server i to player
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
15 Dec 2016 02:14 PM
I don't see what the fuss is.

Just use a local script. You don't need a script for each part, and you ESPECIALLY don't need a clickdetector for each part, whatever its arguments.

There is literally
no
point
to bother with client-server communication in this scenario


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
15 Dec 2016 02:20 PM
Also, @llaser, that MouseClick returns the player doesn't help; the server still can't go in and manipulate the playerGui.

It could add a gui, but it cannot affect an existing child of a playerGui in an FE environment that it did not put there to begin with.


Report Abuse
Neztore is not online. Neztore
Joined: 10 Aug 2014
Total Posts: 56
15 Dec 2016 03:03 PM
So which should I use?
All I see is an argument, I'm not seeing a clear answer
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