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

GUI visible not working? Gui unable to change visibility via script

Hello.

I've written a script (A script parented to ServerScriptService) and I tried to change the visibility of a frame parented to StarterGui.

The problem is that the Gui Visilibility does not become true even though I told it to do so.

After looking through some forums, I realised that it could be because I wasn't using a Local script, so I tried using > :FireAllClients() via a >RemoteEvent.

The thing is, even after using it with a Local script parented to PlayerScripts, the Gui Visibility still doesn't change.

local LocalPlayer = game.Players.LocalPlayer
local RankboardGuiAppearRemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RankboardGuiAppear")
local RankFrameVisibility = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("RankBoard"):WaitForChild("RankFrame").Visible

RankboardGuiAppearRemoteEvent.OnClientEvent:Connect(function()
	RankFrameVisibility = true
	wait(8)
	RankFrameVisibility = false
end)

The code above is the one that starts running when the remote event is fired (dont judge, this is how i write my variables lol, very lengthy)

No error or anything. Got a completely clean Output. What could be the problem here?

Any help is appreciated! Thanks for your time!

1 answer

✓ Accepted answer

Do not set a property to a variable, as it is only gonna be the property's value, it won't lead to the actual property. To fix this, just set the frame to the frame, and add .Visible to the lines in the script:

local LocalPlayer = game.Players.LocalPlayer
local RankboardGuiAppearRemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RankboardGuiAppear")
local RankFrameVisibility = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("RankBoard"):WaitForChild("RankFrame")

RankboardGuiAppearRemoteEvent.OnClientEvent:Connect(function()
    RankFrameVisibility.Visible = true
    wait(8)
    RankFrameVisibility.Visible = false
end)

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