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

Why does this not work?

Asked by 9 years ago

I want the script to do this:

When I click the button called "Open", it would show another frame (by default, it's not visible) Is there something wrong with my script? The button changes the text, but the frame isn't showing up.

P.S. Output shows no errors.

01script.Parent.MouseButton1Click:connect(function()
02    local window = game.StarterGui.ProcessGUI.MainWind
03 
04    if window.Visible == false then
05        window.Visible = true
06        script.Parent.Text = "Close"
07    else
08        window.Visible = false
09        script.Parent.Text = "Open"
10    end
11 
12end)

1 answer

Log in to vote
0
Answered by
DataStore 530 Moderation Voter
9 years ago

The issue with this is the fact that you're editing the gui which is in the StarterGui service. The problem? The player would only see the change if they were to reset, as this service's contents are only given to the player each time they spawn - No link between the two is maintained past this.

The fix? You need to edit the Visible property of "MainWind" in the player's PlayerGui. You can do this by parenting up to it (assuming that this script is in "ProcessGui") or you can get the LocalPlayer and delve into the ProcessGui through their PlayerGui.

Ad

Answer this question