Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my Overhead GUI disappear after respawning?

So, I created an Overhead GUI, and when I respawn it gets removed. I would like it to be there once and always.

ServerScript:

local mS = game:GetService("MarketplaceService")
local gmId = 8004097

game.Players.PlayerAdded:Connect(function(player)
	local ohGUI = game:GetService("ServerStorage"):WaitForChild("OverheadGUI"):Clone()
	local char = player.Character or player.CharacterAdded:Wait()
	if char then
		ohGUI.Parent = char.Head
		local gM = ohGUI.Holder.GoldMember
		local m = ohGUI.Holder.Moderator
		local pN = ohGUI.Holder.PlayerName
		while wait() do
			pN.Text = player.Name
			if player.TeamColor == game:GetService("Teams"):FindFirstChild("Moderation").TeamColor then
				m.TextTransparency = 0.2
			else
				m.TextTransparency = 1
			end
			if mS:UserOwnsGamePassAsync(player.UserId,gmId) == true then
				gM.TextTransparency = 0.2
			else
				gM.TextTransparency = 1
			end
		end
	end
end)

Everything works fine, it just disappears after respawning.

What happens: https://gyazo.com/b5971322854ccfb07c6f74b6140a9552

1 answer

✓ Accepted answer

Use the "CharacterAdded" event in a script under StarterPlayer->StarterPlayerScripts. This will make it so the gui will be added whenever the player's character is added, and not the actual player instance, which only gets added when a player joins, and not when they die or respawn. PS: "CharacterAdded" event is an event under the player instance. You may also put a script under StarterCharacterScripts to add this just once, but that's up to you. Apologies for a very basic answer but it's all I could say without totally giving away the script. :)

PSS: Hard to read, but I hope this helped anyways.

3 comments

0

Thank you

0

It worked, I added player.CharactedAdded:Connect(function(char) under the main script and it works now. Thanks!

0

^^ You're welcome! Have fun scripting!

This discussion is preserved as it was. New answers, comments, and votes are closed.