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 » Scripting Helpers
Home Search
 

Re: Help with this Close and Open GUI script?

Previous Thread :: Next Thread 
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 01:37 PM
Why doesn't this work?
Please can you reply my problem and solution.
Thanks.


x = true
sgui = script.Parent.Parent.Parent
Fr = Script.Parent.Parent

function open()
Fr.Visible = true
end

function close()
Fr.Visible = false
end

function onMouseclick(player)
if x then
close()
x = false
else
open()
x = true
end

end
script.Parent.MouseButton1Click:connect(onMouseclick)

function playerAdded(player)
if sgui.Parent == game.Lighting then
sgui:clone().Parent = player.PlayerGui
end
end
game.Players.PlayerAdded:connect(playerAdded)
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
18 Dec 2012 02:00 PM
x = true
sgui = script.Parent.Parent.Parent
Fr = Script.Parent.Parent

function open()
Fr.Visible = true
end

function close()
Fr.Visible = false
end

script.Parent.MouseButton1Click:connect(function()
if x == true then
close()
x = false
else
open()
x = true
end end)

game.Players.PlayerAdded:connect(function(player)
if sgui.Parent == game.Lighting then
sgui:clone().Parent = player.PlayerGui
end end)



--fixed, but I hope this isn't inside of something in lighting, otherwise it won't run at all.
Report Abuse
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 02:06 PM
Lol, it's in Lighting...
Report Abuse
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 02:07 PM
Where should I put it then? In a Brick in workspace?
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
18 Dec 2012 02:08 PM
Just in a script in workspace is fine. Let me just edit it for you to suit that location
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
18 Dec 2012 02:10 PM
sgui = game.Lighting.ScreenGui -- change to name of gui

game.Players.PlayerAdded:connect(function(player)
sgui:clone().Parent = player.PlayerGui
end)

--put that in the workspace.
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
18 Dec 2012 02:11 PM
The rest of the script can remain inside that Gui in Lighting to make sure when it is copied into the player's gui that it does what you want it to
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
18 Dec 2012 02:11 PM
x = true
Fr = Script.Parent.Parent

function open()
Fr.Visible = true
end

function close()
Fr.Visible = false
end

script.Parent.MouseButton1Click:connect(function()
if x == true then
close()
x = false
else
open()
x = true
end end)

--so this bit stays wherever you put it :)
Report Abuse
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 02:17 PM
Ok, thanks.
I have this in the text button.
x = true
Fr = Script.Parent.Parent

function open()
Fr.Visible = true
end

function close()
Fr.Visible = false
end

script.Parent.MouseButton1Click:connect(function()
if x == true then
close()
x = false
else
open()
x = true
end end)

And I have this inside the Workspace.

sgui = game.Lighting.ScreenGui

game.Players.PlayerAdded:connect(function(player)
sgui:clone().Parent = player.PlayerGui
end)

Is this ok?
Report Abuse
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 02:20 PM
Should I use LocalScripts?
And I fixed "Script" to "script".
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
18 Dec 2012 02:25 PM
Instead of putting that script in Workspace, put the Gui in StarterGui.
Much easier (unless you only want to Gui to come up once when the player enters).

Also, use this in the TextButton,
Fr = script.Parent.Parent
script.Parent.MouseButton1Click:connect(function()
Fr.Visible = not Fr.Visible
end)
-- So much simpler.
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
18 Dec 2012 02:27 PM
Nope, normal scripts should be perfect. Have fun :)
Report Abuse
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 02:27 PM
I would need it in the playergui otherwise once some one closed it, it would result in closing it for everyone.
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
18 Dec 2012 02:29 PM
PlayerGuis are basically clones of StarterGui.

ROBLOX does something like this when you spawn,


Player.CharacterAdded:connect(function()
for n,o in pairs(game.StarterGui:GetChildren())do
o:clone().Parent = Player.PlayerGui
end
end)
Report Abuse
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 02:29 PM
Erm, it's still not working...
The output says "PlayerGui is not a valid member of Player"
Which is GREAT!
...
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
18 Dec 2012 02:31 PM
Just put it in StarterGui, and you'll avoid that problem.
In order to close everyone's you would have to run a for loop on Players, if you close yours, it will ONLY close yours, not anyone elses.
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
18 Dec 2012 02:31 PM
The guy above is right, but if you want to use your scripts its fine if you are just learning :)
Report Abuse
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 02:33 PM
Oh, ok.
Thanks; I will test it.
Report Abuse
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 02:46 PM
I have one last thing.
I want the close/open button to stay Visible.
I also want the text to change for "Close" to "Open"
I do not know how to do this with the new script.
I have taken the textbutton out of the frame so It doesn't turn Invisible with the frame but I would like the text to change.
All I know is:
tb = script.Parent --TextBox
tb.Text = "Open"
open()
else
tb.Text = "Close"
close()

But I have changed the script now to the other shorter one...
Report Abuse
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 02:53 PM
Would this work?

Tb = script.Parent --TextBox
Fr = script.Parent.Parent.Frame --Frame

script.Parent.MouseButton1Click:connect(function()
Rf.Visible = not Rf.Visible
if Rf.Visible == true then
Tb.Text = "Close"
elseif Rf.Visible == false then
Tb.Text = "Open"
end end)


Report Abuse
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 02:58 PM
Wait, I failed...

Tb = script.Parent
Fr = script.Parent.Parent.Frame

script.Parent.MouseButton1Click:connect(function()
Fr.Visible = not Fr.Visible
if Fr.Visible == true then
Tb.Text = "Close"
elseif Fr.Visible == false then
Tb.Text = "Open"
end end)


Report Abuse
1234Christopher is not online. 1234Christopher
Joined: 21 Oct 2008
Total Posts: 1715
18 Dec 2012 03:04 PM
Ok, it works; thanks to all that helped me!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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