I am currently making a 2D obby game and when the user dies I don't want the starter GUI to reappear (which it is currently doing). Currently the StartingScreen (name of GUI) and its localscript is located in startergui (If this needs to be moved tell me!). If there is anyway of doing this that would be great.
LocalScript:
repeat wait() until game.Players.LocalPlayer.Character local character = game.Players.LocalPlayer.Character Start = script.Parent.StartButton CourseSelect = script.Parent.CourseSelect angle = 0 go = 0 CourseSelect.Visible = false Num = 0 Course1 = script.Parent.CourseSelect.Course1 Course2 = script.Parent.CourseSelect.Course2 Course3 = script.Parent.CourseSelect.Course3 Course1.Visible = false Course2.Visible = false Course3.Visible = false -- Size X 400, Size Y 300 print("Started = false") function ClickedStart() CourseSelect.Visible = true Start.Visible = false for GuiSize = 1, 45 do if GuiSize <= 45 then CourseSelect.Size = CourseSelect.Size +UDim2.new(0.01, 0, 0.015, 0) Num = Num +1 print(Num) end wait() end Course1.Visible = true wait(1) Course2.Visible = true wait(1) Course3.Visible = true end function ClickedCourse1() Course1.Visible = false Course2.Visible = false Course3.Visible = false CourseSelect.Visible = false character:MoveTo(game.Workspace.Course1Tele.Position + Vector3.new(0,3,0)) end Course1.MouseButton1Down:connect(ClickedCourse1) Start.MouseButton1Down:connect(ClickedStart)
To make it so a GUI only appears when you start the game, you can use the PlayerAdded event:
local gui = script.StartingScreen -- location of GUI to insert game.Players.PlayerAdded:connect(function(player) repeat wait() until player.PlayerGui gui:Clone().Parent = player.PlayerGui end)
This will insert the GUI only when the player is first added to the game.
Use the hidden ResetPlayerGuiOnSpawn property. It will stop any GUIs from getting removed/reset when your character respawns. http://wiki.roblox.com/index.php?title=ResetPlayerGuiOnSpawn_(Property)
StarterGui is what you get each time you respawn. Therefore, if you make the GUI in StarterGui invisible, each time a player respawns it will be invisible.
However, now you have the problem that if a player joins the game, they won't be able to see it. To fix this, when a player first joins the game make the GUI in their PlayerGui visible. Since PlayerGui is what they are currently seeing, they will be able to interact with the GUI just fine. Once they respawn, however, they will not be able to see the GUI anymore.
In a server script in ServerScriptService or Workspace:
game.Players.PlayerAdded:connect(function(plr) plr:WaitForChild("PlayerGui"):WaitForChild("Name of GUI here").Visible = true end)
If you have GUIs in other GUIs then you will need more WaitForChild()s
That's actually easy : just go in the ScreenGui properties and disable "ResetOnSpawn". That'll make like the gui never existed IF it has been removed before.