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 8 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.

script.Parent.MouseButton1Click:connect(function()
    local window = game.StarterGui.ProcessGUI.MainWind

    if window.Visible == false then
        window.Visible = true
        script.Parent.Text = "Close"
    else
        window.Visible = false
        script.Parent.Text = "Open"
    end

end)

1 answer

Log in to vote
0
Answered by
DataStore 530 Moderation Voter
8 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