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

Removing ScreenGUIs upon spawning?

Asked by
Stam91 0
5 years ago

Okay, so I'm working on a post-nuclear ATF-type RP game, and I have terminals around the map that will explore lore. Clicking on them opens up GUIs that can be read for extra information on the world and other stuff like that.

The GUIs and their associated terminals are working 100% correctly, but the GUIs always appear upon spawning, and I just need a simple script that can prevent them from appearing when joining the game and respawning. I have very little experience with scripting, especially with stuff involving GUIs, so any help would be appreciated.

2 answers

Log in to vote
0
Answered by 5 years ago

Just set the their visibility to false, and enable it whenever you want them to see it.

Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Assuming the local script is inside StarterCharacterScripts this code should work.

local guiCommonName = "blank" -- Assuming all of your lore based UIs have a common name
local guis = script.Parent.Parent.PlayerGui:GetChildren() -- Returns all children as a table
for value in ipairs(guis) do -- ipairs is useful for looping through tables, stopping at the end of the table and more useful abilities.
    if guis[value].Name == guiCommonName then
        guis[value].Enabled = false
    end
end

Whenever a character spawns/respawns scripts inside StarterCharacterScripts will load in with the character, however, when the humanoid dies all scripts that were cloned to the player will be removed. Therefore we can disable the GUI whenever the code runs as the character will have just spawned. I recommend looking up tutorials and at the properties of objects you have not yet learned about on the roblox developer wiki and youtube. Here is a link to a basic gui tutorial. Here is a link to the properties,events and functions of a ScreenGui

0
Its Enabled not Enable Zafirua 1348 — 5y

Answer this question