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

How to clone gui when a player die?

game.Players.PlayerAdded:Connect(function(plr)
	local CloneMe = game.ServerStorage.ClassLoadout:Clone()
	CloneMe.Parent = plr.PlayerGui
end)

how do I make it when a player die it clone the gui

3 answers

Hi bro,

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterRemoving:Connect(function()
    local CloneMe = game.ServerStorage.ClassLoadout:Clone()
    CloneMe.Parent = plr.PlayerGui
end) end)

try this.

1 comment

0

This runs BEFORE the character is removed. It's a much better solution to add this on CharacterAdded

Hello dude, here this might be what you're looking for!

(It's a localscript which you should put in StarterGui)

local Player = game:GetService("Players").LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()

wait(0.25)

character["Humanoid"].Died:Connect(function()
	local CloneMe = game.ServerStorage.ClassLoadout:Clone()
	CloneMe.Parent = plr.PlayerGui
end)

This is probably not what you're looking for, but if you mean like when the player dies, the GUI doesn't disappear, go into the ScreenGUI's properties and turn ResetOnSpawn off.

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