|
| 14 Jul 2015 06:38 PM |
Is it possible to open a gui by clicking on a part with a local script? I tried to make a billboard , but when I wanted to verify if the player name had the same name then then the model it didn't work ,but if I removed the condition it worked,but I want it to only open if the player is the owner of the model. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Jul 2015 06:48 PM |
First, post the code. Here is also a template.
script.Parent.ClickDetector.MouseClick:connect(function(player) --code end)
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 14 Jul 2015 06:55 PM |
Yes
game.Workspace.Part.ClickDetector.MouseClick:connect(function() script.Parent.Visible = true require(Whatever you need to set up the gui) end) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Jul 2015 07:01 PM |
@gooey, You don't need to use a module script for this simple thing. thats overkill.
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 14 Jul 2015 07:10 PM |
Its for the gui setup, its not overkill. I know what I'm doing.
|
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 14 Jul 2015 07:10 PM |
| If you were opening a shop or something, you would want to use a ModuleScript to set it up |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2015 07:12 PM |
Here's the script.
Keep = script.Parent Gui = Keep.Gui player = game.Players.LocalPlayer open = true
function click() if player.Name == Keep.Name then if open == true then Gui.Enabled = false open = false elseif Gui.Enabled == false then Gui.Enabled = true open = true end end end
Keep.ClickDetector.MouseClick:connect(click) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Jul 2015 07:14 PM |
Good for you to know what youre doing. But I'm saying what you are doing is overkill. A module isn't needed, and especially for someone like him. Keep it simple.
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2015 07:18 PM |
| So what do I do now? And I dont wanna do a shop. I just want that only the player that have the same name of his building can open it.Unless he can't. If I remove this condition the stuff work but everyone can open/close. ;/ |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Jul 2015 07:20 PM |
Here is a little bit of code you could use.
script.Parent.ClickDetector.MouseClick:connect(function(player) local gui = player.PlayerGui:WaitForChild("ScreenGui") local frame = gui.Frame if player.Name == script.Parent.Name then frame.Visible = not frame.Visible end end)
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2015 07:25 PM |
| I tried before to put the gui just as a screen gui in the starter gui and to toggle the frame visible, but when I tried.. It didn't work at all. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Jul 2015 07:29 PM |
Post any outpute and look at your script analysis. This should be a server script in a BasePart with click detector in it.
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Jul 2015 07:30 PM |
Also, the parent should be the players name. If this is a model, you need to put the script in the brick then do
script.Parent.Parent.Name
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
| |
|