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: Button to open a GUI?

Previous Thread :: Next Thread 
nirato22 is online. 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
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
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 is not online. 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
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
03 Sep 2017 11:24 AM
^ Blatantly wrong. Why are you changing the Gui in StarterGui?
Report Abuse
dj7679 is not online. 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 is not online. 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 is online. 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 is not online. 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 is not online. lolzmac
Joined: 18 Aug 2012
Total Posts: 96
03 Sep 2017 02:01 PM
^ PlayerGui*



Report Abuse
lolzmac is not online. lolzmac
Joined: 18 Aug 2012
Total Posts: 96
03 Sep 2017 02:02 PM
And ScreenGui* whoops


Report Abuse
nirato22 is online. 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
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
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 is not online. 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 is online. nirato22
Joined: 20 May 2013
Total Posts: 15
03 Sep 2017 02:40 PM
thanks @lolzmac worked ;)
Report Abuse
lolzmac is not online. 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
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