When the Player spawns trough player:loadcharacter() the guis will randomly disappear for no reason, I don’t got a single line that tell the game to delete all guis.
The main menu script: (only the end is important)
LobbyMusic.Volume = 0
TeamChangeButton.Text = "Your Team:\n"..playerteam.."\nClick to Change Team"
player:GetPropertyChangedSignal("TeamColor"):Connect(function()
playerteam =player.Team.Name
end)
local LMT = TweenService:create(LobbyMusic, TweenInfo.new(100), {Volume = 10})
local function MenuON()
MainMenu.Enabled = true
LMT:Play()
LobbyMusic:Play()
LMT.Completed:Wait()
end
player.CharacterAdded:Connect(MenuON)
--task.spawn(MenuON)
local function Play()
if playerteam == Spectators then
PlayButton.Text ="Please Change Your Team"
ErrorSound:Play()
wait(3)
PlayButton.Text ="Play"
else
local LoadCharacter = ReplicatedStorage.LoadCharacter
LoadCharacter:FireServer(player)
SpawnWeaponRE:FireServer(player)
MainMenu:Destroy()
LobbyMusic.Volume = 0
ClickSound:Play()
end
end
PlayButton.MouseButton1Down:Connect(function()
Play()
end)
Basically when pressing the play button the player gets loaded and the main menu destroyed, but it is also destroying all the other GUIs. Even more weird: The StarterGUIs aren’t cloning into the playergui after respawning
Update: Guis are now cloning to PlayerGui
Except: the MainGui which was destroyed, but there is still an MainMenu in starterGui which isn’t getting cloned
Well you said that the UI only disappears when the function LoadCharacter is firing right? Could you also provide the ServerScript? Because I think the issue may lays there
local wfc =game.WaitForChild
local ReplicatedStorage =game:GetService("ReplicatedStorage")
local LoadCharacter =wfc(ReplicatedStorage,"LoadCharacter")
LoadCharacter.OnServerEvent:Connect(function(player)
player:LoadCharacter()
end)
local PlayerGui =wfc(player,"PlayerGui")
repeat wait() until ffc(PlayerGui,"MainMenu")
Basically after the loading finishes, the Loading Script will clone all gui elements to the PlayerGUI AND the StarterGui and destroys itself after.
It’s supposed that the StarterGui clones the MenuGui tothe playerGui each time the player dies
but the mainmenu isn’t either getting detected or my script is just broken
Well I had different ScreenGui, but I kinda fixed the Error, I enabled ResetonSpawn, and also added the LoadCharacter at the teamchange button
Also changed it a bit tho, now im struggeling with something other
function MenuON()
local LMT = TweenService:create(LobbyMusic, TweenInfo.new(100), {Volume = 10})
--if not ffc(PlayerGui,"MainMenu") then
print("TTTTT")
MainMenu:Clone().Parent = PlayerGui
LMT:Play()
LobbyMusic:Play()
--LMT.Completed:Wait()
--end
end
player.Humanoid.Died:Connect(MenuON)
--task.spawn(MenuON)
function Play()
local LMT = TweenService:create(LobbyMusic, TweenInfo.new(100), {Volume = 10})
if playerteam == Spectators then
PlayButton.Text ="Please Change Your Team"
ErrorSound:Play()
wait(3)
PlayButton.Text ="Play"
else
SpawnWeaponRE:FireServer()
MainMenu:Destroy()
LMT:Play()
LMT:Cancel()
LobbyMusic.Volume = 0
LobbyMusic:Stop()
ClickSound:Play()
end
end
basically, the tween is only stopping in the Play() function when it is played again
when the player spawns then the MenuON() function isn’t player for some reason