Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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!

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. baldi92102 2 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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.

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. baldi92102 2 — 4y
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. baldi92102 2 — 4y
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! baldi92102 2 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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

0
maybe it is a snippet of his actual code greatneil80 2647 — 4y
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. baldi92102 2 — 4y

Answer this question