nirato22
|
  |
| Joined: 20 May 2013 |
| Total Posts: 15 |
|
|
| 03 Sep 2017 11:06 AM |
i made a script like this:
local a = game.StarterGui.ScreenGUI.Frame
local b = script.Parent local ClickDetector = b:WaitForChild("ClickDetector")
ClickDetector.MouseClick:connect(function(player) a.Visible = true end)
but the GUI doesn't open how i can make this functional? |
|
|
| Report Abuse |
|
|
|
| 03 Sep 2017 11:12 AM |
local b = script.Parent local ClickDetector = b:WaitForChild("ClickDetector")
ClickDetector.MouseClick:connect(function(player) player.PlayerGui.ScreenGui.Frame.Visible = true end)
in essence |
|
|
| Report Abuse |
|
|
JellyYn
|
  |
| Joined: 02 Sep 2015 |
| Total Posts: 732 |
|
|
| 03 Sep 2017 11:20 AM |
^ Wrong
local a = game.StarterGui.ScreenGUI.Frame local b = script.Parent
local ClickDetector = b:WaitForChild("ClickDetector") open = false
ClickDetector.MouseClick:connect(function(player) if open == false then a.Visible = true end end)
i will have a multi-line siggy if i want |
|
|
| Report Abuse |
|
|
|
| 03 Sep 2017 11:24 AM |
| ^ Blatantly wrong. Why are you changing the Gui in StarterGui? |
|
|
| Report Abuse |
|
|
dj7679
|
  |
| Joined: 11 Jun 2013 |
| Total Posts: 307 |
|
|
| 03 Sep 2017 11:27 AM |
| Use Enum.keycode instead less likely to give an error. |
|
|
| Report Abuse |
|
|
JellyYn
|
  |
| Joined: 02 Sep 2015 |
| Total Posts: 732 |
|
|
| 03 Sep 2017 11:30 AM |
Sorry, forgot to do that (here is the fix)
local a = game.Players.LocalPlayer.PlayerGui:FindFirstChild("ScreenGUI").Frame local b = script.Parent
local ClickDetector = b:WaitForChild("ClickDetector") open = false
ClickDetector.MouseClick:connect(function(player, Open) -- forgot to add "Open" here too if open == false then a.Visible = true end end)
the "open = false" is a debounce, to make the script function better, and know whether the gui is open or not
i will have a multi-line siggy if i want |
|
|
| Report Abuse |
|
|
nirato22
|
  |
| Joined: 20 May 2013 |
| Total Posts: 15 |
|
|
| 03 Sep 2017 01:48 PM |
| ^ jelly, This script you made is not working , Do you have any idea why? |
|
|
| Report Abuse |
|
|
lolzmac
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 96 |
|
|
| 03 Sep 2017 02:00 PM |
local a=game.Players.LocalPlayer.PlayerGUI.ScreenGUI.Frame
local b=script.Parent local clickdetector=b:WaitForChild("ClickDetector")
function clicked() a.Visible=true end
ClickDetector.MouseClICK:connect(clicked)
|
|
|
| Report Abuse |
|
|
lolzmac
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 96 |
|
| |
|
lolzmac
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 96 |
|
| |
|
nirato22
|
  |
| Joined: 20 May 2013 |
| Total Posts: 15 |
|
|
| 03 Sep 2017 02:14 PM |
^ Workspace.Block.Part.Script:1: attempt to index field 'LocalPlayer' (a nil value)
(Error in Output) |
|
|
| Report Abuse |
|
|
|
| 03 Sep 2017 02:23 PM |
| That would have to be in a LocalScript, which wouldn't run in a part in workspace. Did you try mine? |
|
|
| Report Abuse |
|
|
lolzmac
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 96 |
|
|
| 03 Sep 2017 02:29 PM |
local b=script.Parent local clickdetector=b:WaitForChild("ClickDetector")
clickdetector.MouseClick:connect(function(plr) plr.PlayerGui.ScreenGui.Frame.Visible=true end)
Perhaps it's because localplayer can only be used in a localscript? This script should work since I tested it in studio.
|
|
|
| Report Abuse |
|
|
nirato22
|
  |
| Joined: 20 May 2013 |
| Total Posts: 15 |
|
| |
|
lolzmac
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 96 |
|
|
| 03 Sep 2017 02:45 PM |
No problem, although I kinda copied that bunny guy without even realizing it. whoops
|
|
|
| Report Abuse |
|
|