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

My GUI wont go away when I click the X button?

Asked by 6 years ago
Edited 6 years ago

So I made an Intro gui thats just a ImageLabel with a X button I made with the TextButton. I looked up a tutorial but the script didnt work for me when I tried to click the X.

script.Parent.MouseButtonClick:connect(function()script.Parent.Parent.Visible=false

end)
0
After they click the button, will the gui show ever again? 222ono222 47 — 6y
0
No the GUI doesnt even go away Shaletsgo 8 — 6y

4 answers

Log in to vote
0
Answered by
GingeyLol 338 Moderation Voter
6 years ago

its .MouseButton1Click your organization is also messed up

script.Parent.MouseButton1Click:Connect(function(lol)
    script.Parent.Parent.Visible = false
end)
0
Perfect it works! But is there a way to make the GUI not pop up again? Shaletsgo 8 — 6y
0
:Destroy() GingeyLol 338 — 6y
1
To answer your question, Shaletsgo, in the ScreenGui properties, there's a property called "ResetOnSpawn." Make sure that isn't checked. TheRings0fSaturn 28 — 6y
0
tysm :D Shaletsgo 8 — 6y
Ad
Log in to vote
1
Answered by 6 years ago

Referencing GingeyLol, this is another way to do it using input:

UIS = game:GetService("UserInputService")
while true do
    wait()
    if UIS:IsKeyDown(Enum.KeyCode.O) then -- Open GUI
        for _,p in pairs(game.Players:GetPlayers()) do
            p.PlayerGui.ScreenGui.Enabled = true
        end
    end
    if UIS:ISKeyDown(Enum.KeyCode.X) then -- Close GUI
        if game.StarterGui.ScreenGui.Enabled ~= false then
            for _,p in pairs(game.Players:GetPlayers()) do
                p.PlayerGui.ScreenGui.Enabled = false
            end
        end
    end
end

Log in to vote
0
Answered by 6 years ago

Ok, so I think I understand what you need.

First off, you need to put it in a local script. (Always a local script if it's in the StarterGui)

After that, you may want to destroy the gui completely. Using a simple method, you can do this efficiently.

script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent:Destroy()

Hope this helped.

Sincerely, 222ono222

0
So I put that into a local script in the textbutton but It still didnt work Shaletsgo 8 — 6y
0
Nevermind I added a End on the 3rd line and it went away but is there a way to make it not pop up after a player resets Shaletsgo 8 — 6y
0
Yeah, just go into the screengui and turn off 'ResetOnSpawn' 222ono222 47 — 6y
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

myScreenGui = script.Parent -- you're path

game.Players.PlayerAdded:Connect(function(player)

if not player then repeat wait() until game.Players.LocalPlayer end

player.CharacterAdded:Connect(function(character)

if not character then repeat wait() until player.Character end

if not player:FindFirstChild("PlayerGui") then repeat wait until player.PlayerGui end

for i,v in pairs(player.PlayerGui:GetChildren()) do

if v.Name == myScreenGui.Name then

ScreenGui = v

else

return

end

end

if character.Humanoid.Died:Wait() then

character.Humanoid.Died:Connect(function()

if ScreenGui.ResetOnSpawn == false then ScreenGui.ResetOnSpawn == true

end

if ScreenGui.ResetOnSpawn == true then

0
It didnt work Shaletsgo 8 — 6y
0
still doesnt work Shaletsgo 8 — 6y

Answer this question