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: Why doesn't this work?

Previous Thread :: Next Thread 
Jurok is not online. Jurok
Joined: 26 Feb 2012
Total Posts: 13387
11 Jul 2013 10:57 PM
[Note: I am a beginner scripter, so I apologize if my script is far beyond improperly formatted. All I ask of is help, thank you.]

So, what I'm trying to do is make a simple guide GUI where you click a button, it makes a text box (grouped with text labels.) visible, and once you click it again, it's invisible. (I want it to start out as invisible.) Though, this script does not work, and I do not understand why. Could anyone help debug it? Thanks in advance.

-----------------------------------------------------------------------------------------------------------------
-- Scripted by Jurok.

opened = 1
game.StarterGui.Guide.GuideButton.Text = "Click here for a guide."
game.StarterGui.GuideWindow.Visible = false


while true do
gui.MouseButton1Click:connect(function()
if opened == 1 then
game.StarterGui.Guide.GuideButton.Text = "Click to close."
game.StarterGui.GuideWindow.Visible = true
elseif opened == 0
game.StarterGui.Guide.GuideButtion.Text = "Click here for a guide."
game.StarterGui.GuideWindow.Visible = false
end)
end)
----------------------------------------------------------------------------------------------------------------
(Also, yes. This is in StarterGui.)

signatures are for losers!!! wait
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
11 Jul 2013 11:05 PM
First off use the PlayerGui found in a Player. Do not use StarterGui since you will only see it change when you reset.

gui = put the path to the gui
txtb = put the path to the txt button
msg1 = "Click to close."
msg2 = "Click he for a guide."

txtb.Text = tostring(msg1)
txtb.Visible = false

txtb.MouseButton1Click:connect(function()
if txtb.Text == msg1 then
txtb.Text = msg2
txtb.Visible = true
else
txtb.Text = msg1
txtb.Visible = false
end)
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
11 Jul 2013 11:05 PM
The player doesn't see Starter GUI, they see Player GUI


StarterGui is what they are given when they spawn each time.

PlayerGui is the GUI's in their backpack.

Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
11 Jul 2013 11:06 PM
Well, not backpack, it's the GUI's they see.

So put the script into the button they click on.

You can even make it a local script.

Then just to

script.Parent.Parent as many times as you need to get to the main frame of the GUI, and you can manipulate the parts of it from there.
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
11 Jul 2013 11:08 PM
Also, you don't need "while true do"

The function you declared waits on the MouseButton1Click event.

So whenever it's clicked, it runs that code. EVERY time it is clicked, it runs that code. You don't need to loop it.
Report Abuse
Jurok is not online. Jurok
Joined: 26 Feb 2012
Total Posts: 13387
11 Jul 2013 11:10 PM
Huh, it isn't working.

signatures are for losers!!! wait
Report Abuse
Jurok is not online. Jurok
Joined: 26 Feb 2012
Total Posts: 13387
11 Jul 2013 11:12 PM
@Dr
Could you explain it a little simpler, please...?
Because I got none of that...

signatures are for losers!!! wait
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
11 Jul 2013 11:13 PM
Put the script into the button you want to be clicked.

function onClick()
if not debounce then
debounce = true

GUIThatIWantVisible = Path to it FROM THE SCRIPT, so use script.Parent's
GUIThatIAmUsingNow = Path to it FROM THE SCRIPT, so use script.Parent's

GUIThatIWantVisible.Visible = true
GUIThatIAmUsingNow.Visible = false

debounce = false
end
end

script.Parent.MouseButton1Click:connect(onClick)
Report Abuse
Jurok is not online. Jurok
Joined: 26 Feb 2012
Total Posts: 13387
11 Jul 2013 11:16 PM
So wait... where do I place the GUI? Workspace, StarterGUI, or what? I am completely confused right now.

signatures are for losers!!! wait
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
11 Jul 2013 11:17 PM
Actually let me modify yours so that you see it easier from your way of scripting. I didn't learn the fancy way for functions.

opened = 1
script.Parent.Parent.Guide.GuideButton.Text = "Click here for a guide."
script.Parent.Parent.Parent:FindFirstChild("GuideWindow").Visible = false

[MIGHT NEED TO CHANGE THOSE PATHS]

script.Parent.MouseButton1Click:connect(function()
if opened == 1 then
local gui = script.Parent.Parent
gui.GuideButton.Text = "Click to close."
gui.Parent:FindFirstChild("GuideWindow").Visible = true
elseif opened == 0
gui.GuideButtion.Text = "Click here for a guide."
gui.Parent:FindFirstChild("GuideWindow").Visible = false
end)
end)

Check the paths, ensure they're correct.
Report Abuse
cxcharlie is not online. cxcharlie
Joined: 26 Aug 2009
Total Posts: 1414
11 Jul 2013 11:17 PM
starter GUI...
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
11 Jul 2013 11:20 PM
The StarterGui is the place you put all of the GUI's your player will get when they respawn. When they do respawn, every GUI in StarterGui is copied, and placed into the PlayerGui, located inside of the player.

When they respawn, the player sees their PlayerGui, not the StarterGui, so changing StarterGui does nothing to the player screen, unless they reset and get the StarterGui's items again.

Therefore, if you place the script INTO the GUI Button you want them to click, when it gets copied, they are able to change their visible GUI around, and only for them. You can also use script.Parent.Parent.Child.Child or however you need to, to find parts of the PlayerGui, so you don't have to go from game.Players.PlayerGui.MYSWEETGUI.MYSUPERCOOLBUTTON.Script
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