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

When player dies, GUI's won't be re-placed into the PlayerGui?

I'm probably over complicating myself, but what I'm trying to do is when the player joins, it clones a GUI into their PlayerGui (Works) but then when they die, the gui re-appears (Which it doesn't)

game.Players.PlayerAdded:connect(function(Player) --Works
	if Player:GetRankInGroup(groupID) >= rankID then --Works
		local gui = script.DetChange:Clone() --Works
		gui.Parent = Player.PlayerGui --Works
		Player.CharacterAdded:connect(function(char) --Works
			char.Humanoid.Died:connect(function() --Doesn't work
				local gui = script.DetChange:Clone() --Doesn't work
				gui.Parent = Player.PlayerGui --Doesn't work
			end)
		end)
	end
end)

2 answers

✓ Accepted answer

Try just removing the died event.

The CharacterAdded event fires after they die, meaning the died event isn't really necessary.

game.Players.PlayerAdded:connect(function(Player)
    if Player:GetRankInGroup(groupID) >= rankID then
        local gui = script.DetChange:Clone()
        gui.Parent = Player.PlayerGui 
        Player.CharacterAdded:connect(function(char)
            local gui = script.DetChange:Clone() 
            gui.Parent = Player.PlayerGui 
        end)
    end
end)

I hope that works for you.

Good Luck

2 comments

1

.-. Why is it I always over-complicate stuff. Can I give you like 99% of my brain?

0

:3

You could possibly try If Humanoid.Health = 0 then Wait(5) Then get it to call the gui again.

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