My GUI is not changing its contents after the player dies and respawns!

I made a shooting game, Where a GUI shows the number of bullets and reloads rounds left, But, when the player dies, the ScreenGUI containing the TextLabel doesn’t change its Texts

The script and the ScreenGUI is in the StartGUI folder

Any help would be appreciated
Thanks in Advance!

set ResetOnSpawn to true or use

local newUi

player.CharacterAdded:Connect(function()
newUi = ui:Clone()
newUi.Parent = player.PlayerGui
end)

humanoid.Died:Connect(function()
newUi:Destroy
end)

2 Likes

I had set my ResetOnRespawn to false because my loading screen and Home Screen is in the same Screen GUI and would show up every time I die if it was True

Then modify this

local newUi

player.CharacterAdded:Connect(function()
newUi = ui:Clone()
newUi.Parent = player.PlayerGui
end)

humanoid.Died:Connect(function()
newUi:Destroy
end)

Isn’t that the same thing. Like just creating a new object of the GUI?

The script has the code to start it from Loading screen

ye but u can modify it so it creates after your homescreen

with a remote/ bindable event
cjsjakaola

Should I create 2 scripts or one with some RemoteEvents?

idk i would do smth like this

player.charadded:connect()
repeat task.wait () until homescreen.visible = false
–code

or if you have a button
button.activated:connect()
remote:fire()

remote.event:connect()
newui = …

I have this one to detect the Player Death in the PlayerStarterScripts

character:WaitForChild("Humanoid").Died:Connect(function(player)

deatroy the ui in that function

		LPDied:FireServer(1)

I used RemoteEvent but the GUI script doesn’t catch it and displays output that Remote Event has been dropped

is that for destroying the bullet uo or creating a new one?

Can I use like Variables in game.ReplicatedStorage to check if player is playing the game, to directly send the player’s GUI to the gamePlayFrame

No. When player Dies I fire that remote event
LPDied:FireServer(1)

yes i would advise to be carefull you need to create and change variablesnon the server

Ok, I’ll try that and come back if its not working

you also dont need this, use this instead:

game.Players.PlayerAdded:Connect(function(player)
local character = player.Character
local humanoid = character:FindFirstChildOfClass("Humanoid")
humanoid.Died:Connect(function()
--code
end)
end)