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

How this script failed?

Asked by 10 years ago
Frame2 = game.StarterGui.ScreenGui.Frame
Button = script.Parent

function onClick()
    Frame2.Visible = true
end

Button.MouseButton1Click:connect(onClick)

What is wrong!?

2 answers

Log in to vote
1
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

StarterGui is where you put GUI's that will replicate to the player's PlayerGui. You edit the GUI in PlayerGui to display any changes instantly.

-- LocalScript in the ScreenGui
local plr = game.Players.LocalPlayer
--You may need to fix these
local Frame2 = script.Parent:WaitForChild("Frame")
local Button = Frame2:WaitForChild("TextButton")

function onClick()
    if Frame2.Visible then 
        Frame2.Visible = false
    else
       Frame2.Visible = false
    end
end

Button.MouseButton1Click:connect(onClick)
Ad
Log in to vote
-4
Answered by 10 years ago

Several Things that might brake the script...

1. I am not positive, but "MouseButton1Click" may be wrong. Even if it is technically correct, try something like MouseButton1Down

2. Try messing around when the arguments in the function. A variable might not be carrying over

  1. It may just be the formatting on scriptinghelpers, but to me the computer sees Frame2 as "Frame" "2" not one name of "Frame2"

Hope this helps!

Answer this question