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

I need my GUI to open when a player joins or opens GUI, but not when they die. How?

Asked by 4 years ago

I've received complaints from my players about the welcome GUI being annoying as it pops up when you respawn, not just when you join the game or click the open introduction button. I have tried my best but not succeeded in getting my script to make the GUI open at these times.

Here is the code I started off with:

local frame = script.Parent.Parent.IntroGUI
local open = false

script.Parent.MouseButton1Click:Connect(function()
    if frame.Visible == false then
    frame.Visible = true
    end
end)

This is the script I have now, and this does the same as the one before, only more lengthy. This was an attempt to make is so that the problem is fixed, however it has not worked.

local frame = script.Parent.Parent.IntroGUI
local open = false

if game.Players.PlayerAdded == true then
    frame.Visible = true
elseif script.Parent.MouseButton1Click then
    script.Parent.MouseButton1Click:Connect(function()
        if frame.Visible == false then
            frame.Visible = true
        end
    end)
    else
        frame.Visible = false
end

This is my GUI tree:
file:///Users/adam/Desktop/Screenshot%202020-05-01%20at%2011.24.59.png

And this is my GUI:
file:///Users/adam/Desktop/Screenshot%202020-05-01%20at%2011.25.40.png

This is the script for my GUI close button:

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Visible = false
end)

Hope someone can help!

0
Because you have player added in your script, the method I showed you won't work, as scripts override what you set the properties to in the Studio if you have the script change the properties. AntiWorldliness 868 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

It's actually easier than you think. There is a property for every GUI called "ResetOnSpawn". Just go to it in Properties for your GUI and set it to false. Then it will not show up when a player respawns.

Ad

Answer this question