Need help with ScreenGui script

Here is my code:

local Frame = script.Parent
local No = script.Parent.No
local Yes = script.Parent.Yes
local MainLabel = script.Parent.MainLabel
local NoOne = script.Parent.NoOne
local YesOne = script.Parent.YesOne
local ImageLabelYes = script.Parent.Yes.ImageLabel
local ImageLabelYesOne = script.Parent.YesOne.ImageLabel
local ImageLabelNo = script.Parent.No.ImageLabel
local ImageLabelNoOne = script.Parent.NoOne.ImageLabel

Yes.MouseButton1Click:Connect(function()
	MainLabel.Text = ("You Should Be. Are You Afraid Of The Dark?")
	No.Active = false
	NoOne.Active = true
	ImageLabelNo.Active = false
	ImageLabelNoOne.Active = true
	Yes.Active = false
	YesOne.Active = true
	ImageLabelYes.Active = false
	ImageLabelYesOne.Active = true
	
No.MouseButton1Click:Connect(function()
	MainLabel.Text = ("How Interesting. I'm Sure Your Answer Will Soon Change. Are You Afraid Of The Dark")
		Yes.Active = false
		YesOne.Active = true
		ImageLabelYes.Active = false
		ImageLabelYesOne.Active = true
		No.Active = false
		NoOne.Active = true
		ImageLabelNo.Active = false
		ImageLabelNoOne.Active = true
end)	
end)

Here is what my explorer looks like:

Basically I’m trying to make it to where you press either the Yes or No TextButton, some specific properties will change. But my code does not seem to work and I don’t know why. I am trying to learn scripting and this is my first attempt at doing so. Any help would be cool.

1 Like

What properties and what do you want to be changed?

1 Like

Try using .Visible instead of .Active, it should fix your problem.

2 Likes

You’re right, I should have used Visible instead of Active, but the code still doesn’t work… any other suggestions?

Trying to make the MainLabel say something different when you press the Yes Button or No button. I want the MainLabel to say something different if you press the Yes button and something different if you press the No button. Is there a better way to do this?

Remove the parentheses from the strings, it should work now.

The script still does not work.

I’ve updated the code but it still doesn’t work:

local Frame = game.StarterGui.ScreenGui.MainFrame
local No = script.Parent.No
local Yes = script.Parent.Yes
local MainLabel = script.Parent.MainLabel
local NoOne = script.Parent.NoOne
local YesOne = script.Parent.YesOne

MainLabel.Text = "Let's Begin. Are You Nervous?"

Yes.MouseButton1Click:Connect(function(player)
	MainLabel.Text = "You Should Be. Are You Afraid Of The Dark?"
	No.Visible = false
	NoOne.Visible = true
	Yes.Visible = false
	YesOne.Visible = true
	
No.MouseButton1Click:Connect(function(player)
	MainLabel.Text = "How Interesting. I'm Sure Your Answer Will Soon Change. Are You Afraid Of The Dark"
		Yes.Visible = false
		YesOne.Visible = true
		No.Visible = false
		NoOne.Visible = true
end)	
end)
1 Like

And like I said, I’m trying to change the MainLabel when you press the Yes or No buttons. The MainLabel says something different if you press the Yes button and it says something different when you press the No button. I made it where if you press the Yes or No button the Yes and No buttons are not visible anymore and two new buttons are now visible and take their place. Is there a better way to accomplish my goal?

You put the “end)”'s in the wrong place

local Frame = game.StarterGui.ScreenGui.MainFrame
local No = script.Parent.No
local Yes = script.Parent.Yes
local MainLabel = script.Parent.MainLabel
local NoOne = script.Parent.NoOne
local YesOne = script.Parent.YesOne

MainLabel.Text = "Let's Begin. Are You Nervous?"

Yes.MouseButton1Click:Connect(function(player)
	MainLabel.Text = "You Should Be. Are You Afraid Of The Dark?"
	No.Visible = false
	NoOne.Visible = true
	Yes.Visible = false
	YesOne.Visible = true
end)

No.MouseButton1Click:Connect(function(player)
	MainLabel.Text = "How Interesting. I'm Sure Your Answer Will Soon Change. Are You Afraid Of The Dark"
		Yes.Visible = false
		YesOne.Visible = true
		No.Visible = false
		NoOne.Visible = true	
end)

Also why do you have “player” inside of your function if it’s not being used?

It still doesn’t work, and I have “player” inside of the function because I looked at another script as a reference. I’m new at scripting so I don’t really know any better lol. At least I now know that I don’t need to put anything inside of the function and that I can just leave it blank.

Hello! Can you tell me if you’re getting any errors on the output window?

What specific part is not working? Is the script not working or is the thing that you wanted to achieve not happening

No errors in the output window. No errors or anything.

I’m trying to make it where you press the Yes or No button the MainLabel text changes. I want the MainLabel to say something different if you press the Yes button and something different if you press the No button. Nothing is happening when I press the buttons.

Also please don’t read this and think I’m crazy… I’m really new to scripting. I’m a builder and I want to learn.

It’s alright! It seems as you forgot to make the MainLabel visible when clicking the Yes button and No button. Try the following code and let me know how it goes:

local Frame = script.Parent
local No = script.Parent.No
local Yes = script.Parent.Yes
local MainLabel = script.Parent.MainLabel
local NoOne = script.Parent.NoOne
local YesOne = script.Parent.YesOne
local ImageLabelYes = script.Parent.Yes.ImageLabel
local ImageLabelYesOne = script.Parent.YesOne.ImageLabel
local ImageLabelNo = script.Parent.No.ImageLabel
local ImageLabelNoOne = script.Parent.NoOne.ImageLabel

Yes.MouseButton1Click:Connect(function()
	MainLabel.Text = ("You Should Be. Are You Afraid Of The Dark?")
MainLabel.Visible=true
	No.Visible= false
	NoOne.Visible= true
	ImageLabelNo.Visible= false
	ImageLabelNoOne.Visible= true
	Yes.Active = false
	YesOne.Visible= true
	ImageLabelYes.Visible= false
	ImageLabelYesOne.Visible= true
	
No.MouseButton1Click:Connect(function()
	MainLabel.Text = ("How Interesting. I'm Sure Your Answer Will Soon Change. Are You Afraid Of The Dark")
MainLabel.Visible=true
		Yes.Visible= false
		YesOne.Visible= true
		ImageLabelYes.Visible= false
		ImageLabelYesOne.Visible= true
		No.Visible= false
		NoOne.Visible= true
		ImageLabelNo.Visible= false
		ImageLabelNoOne.Visible= true
end)	
end)

Still doesn’t work. The MainLabel is already visible anyway. Is there an easier or different way to achieve what I’m trying to achieve? I feel very bummed out that I can’t script something simple like this.

Would you mind giving me the .rbxl place file for the game? I’ll try to search for the problem and give you a fix for it. You can do so by going up to File > Save to File as… then send it here. Thanks!