Basically struggling to have the gui stay there with it set to false
This is what i tried, and of course it didnt work
local MenuGui = game.StarterGui.Main
if game.StarterGui:FindFirstChild("Main") then
MenuGui.Parent = game.ReplicatedStorage
end
----
function AddGui(Player)
local gui = MenuGui:Clone()
gui.Parent = Player.PlayerGui
end
function AddedPlayer(Player)
AddGui(Player)
Player.CharacterAdded:Connect(function(Character)
AddedCharacter(Character, Player)
end)
end
(Some code has been cut out, shouldn’t matter to much what it was)
I’m not sure if you ever actually load the character or not but, this may be because the CharacterAdded event will only fire if CharacterAutoLoads is set to true. Try making your own bindable event for when you manually load the character, or call the AddedCharacter function everytime you manually load the character.
yea, the character event is fine, ill just show the entire script
local Players = game.Players
Players.CharacterAutoLoads = false
local MenuGui = game.StarterGui.Main
if game.StarterGui:FindFirstChild("Main") then
MenuGui.Parent = game.ReplicatedStorage
end
function OnSpawnIn(Gui, Player, Character)
end
function AddGui(Player)
local gui = MenuGui:Clone()
gui.Parent = Player.PlayerGui
end
function PlayerDied(Player)
wait(2)
Player.Character:Remove()
Player.PlayerGui.Main.Menu.Visible = true
end
function AddedCharacter(Character, Player)
OnSpawnIn(Player.PlayerGui.Main, Player, Character)
Player.PlayerGui.Main.Menu.Visible = false
print(Player.PlayerGui.Main.Menu)
print(1)
Character.Humanoid.Died:Connect(function()
PlayerDied(Player)
end)
end
function AddedPlayer(Player)
AddGui(Player)
Player.CharacterAdded:Connect(function(Character)
AddedCharacter(Character, Player)
end)
end
Players.PlayerAdded:Connect(AddedPlayer)
If you don’t need to reset the gui you can set the ResetOnSpawn property of the ScreenGui to false, and when the player dies the UI wont be removed from the players PlayerGui