Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i fix this script? It doesnt say an error message but it's like the script isnt even there...

Hierarchy:

> game
> 	StarterGui
> 			SurfaceGui
> 					TextButton
> 							LocalScript

Script:

local label = game.StarterGui.ScreenGui.TextLabel
local button = script.Parent

button.MouseButton1Click:Connect(function()
	if label.Visible == true then
		label.Visible = false
	
elseif label.Visible == false then
	label.Visible = true
	end
end)

7 comments

0

where is the local script?

0

SurfaceGui's aren't meant to be used in StarterGui, I think you're talking about ScreenGui?

0

yeah its screen sorry.

0

and put your localscript inside of the button and write script.Parent.MouseButton1Click:Connect(function() --// Rest of code

0

well it is in the button and ill fix that

0

its not working

0

You can’t reference any and all GUIs through StarterGui if you desire to provide functions that modify the players UI live. If this is what you want, you must reference PlayerGui instead.

1 answer

LocalScript inside of the button and write this.

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Parent.TextLabel.Visible == true then
		script.Parent.Parent.TextLabel.Visible = false
	elseif script.Parent.Parent.TextLabel.Visible == false then
		script.Parent.Parent.TextLabel.Visible = true
	end
end)

Any changes you make in the StarterGui will not have an affect on the player's screen.

Hope this helped! If this worked, don't forget to select this as an answer!

Hierarchy (Setup)

This discussion is preserved as it was. New answers, comments, and votes are closed.