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

Why can't I make my GUIS visible and invisible using a script?

So I am just doing a simple thing, making GUIs invisible when you click on a certain button. For some reason, the buttons are going invisible but you can't script it to become visible again. This might be because I have used the roundify plugin on the text buttons but I am not sure. This is my code.


ClickDetector1.MouseClick:Connect(function()
	script.Parent.Parent.Stats.TextButton.Visible = false
	script.Parent.Parent.Storage.TextButton.Visible = false
	script.Parent.Parent.ScreenGui.TextLabel.Visible = false
end)

No.MouseButton1Click:Connect(function()
	script.Parent.Parent.Stats.TextButton.Visible = true
	script.Parent.Parent.Storage.TextButton.Visible = true
	script.Parent.Parent.ScreenGui.TextLabel.Visible = true
end)


Close.MouseButton1Click:Connect(function()
	script.Parent.Parent.Stats.TextButton.Visible = true
	script.Parent.Parent.Storage.TextButton.Visible = true
	script.Parent.Parent.ScreenGui.TextLabel.Visible = true
end)

Yes.MouseButton1Click:Connect(function()
	wait(10)
	script.Parent.Parent.ScreenGui.TextLabel.Visible = false
end)

Shop.MouseButton1Click:Connect(function()
	script.Parent.Parent.ScreenGui.TextLabel.Visble = false
	script.Parent.Parent.ScreenGui.TextLabel.Position = UDim2.new(0.386, 0,0.057, 0)
end)

Please be aware that where the visible check is in the properties tab, it is ticking on and off when I want it to, but it is not physically becoming visible, even if the visible property in the properties tab is ticked on. Thank you if you can help!

1 comment

0

By the way, I can just make the GUIS go off the screen and that would make it "invisible" but it will be more complicated to do. Just wanted to figure out why the visible thing isn't working.

2 answers

✓ Accepted answer

You need to use a LocalScript when you want the client can interact with a UI. So change up the Script (ServerScript) to a LocalScript (ClientScript) that you putting in your ScreenGui.

I recommand found the ScreenGui with the PlayerService (Players) and not with the Parent of the Instance.

local PlayerService = game:GetService('Players') -- You can see this Folder in the explorer.

local Player = PlayerService.LocalPlayer -- LocalScript only, this is you.

local PlayerGui = Player:WaitForChild('PlayerGui') -- Here is your ScreenGui

local ScreenGui = PlayerGui:WaitForChild('ScreenGui') -- Change "ScreenGui" to the name of yours

Use WaitForChild to prevent errors.

Now to fix your ClickDetector, use a Script (ServerScript). When a Client click on a ClickDetector a argument is sent and this argument is the client.

ClickDetector1.MouseClick:Connect(function(Player)
	local PlayerGui = Player:WaitForChild('PlayerGui')
	local ScreenGui = PlayerGui:WaitForChild('ScreenGui') -- Change "ScreenGui" to the name of yours

	ScreenGui.Stats.TextButton.Visible = false
	ScreenGui.Storage.TextButton.Visible = false
	ScreenGui.ScreenGui.TextLabel.Visible = false
end)

Hope this help, to more questions put bellow on commentaries.

3 comments

0

WaitForChild is always a good thing to use, but I don't think it helps here when the player clicks on the click detector at least a minute after the player themself have loaded in. I also used a local script, sorry for being vague by using the term "script". I put the local script into starter gui.

0

Also, I want the guis to disappear locally, and I don't think putting different scripts is the solution as I mentioned in my question, the visible property in the properties tab is ticking on and off when I want to, but it is not actually disappearing on the players screen, even if the visible property is ticked off in the properties tab. Sorry if it is a bit confusing.

0

Perhaps, it may be a problem with the plug in I am using which is called roundify which makes guis round by inserting an image label or button into the text button itself and makes the background transparency of both the image label/button and the normal button to 1. Thank you for your help on this problem! I really appreciate it!

This script doesn't work because you don't define what ClickDetector1, No, Close, and Shop are.

2 comments

0

maybe it is a snippet of his actual code

0

Yes it is a snippet. As i said, the visible property in the properties tab is checking in and not checking when I want it to, but it is not physically disappearing even if visible = false.

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