Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to clone gui when a player die?

Asked by
jnsan56 -31
5 years ago
1game.Players.PlayerAdded:Connect(function(plr)
2    local CloneMe = game.ServerStorage.ClassLoadout:Clone()
3    CloneMe.Parent = plr.PlayerGui
4end)

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

3 answers

Log in to vote
0
Answered by
gloveshun 119
5 years ago

Hi bro,

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

try this.

0
This runs BEFORE the character is removed. It's a much better solution to add this on CharacterAdded User#834 0 — 5y
Ad
Log in to vote
0
Answered by
VitroxVox 884 Moderation Voter
5 years ago

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

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

1local Player = game:GetService("Players").LocalPlayer
2local character = Player.Character or Player.CharacterAdded:Wait()
3 
4wait(0.25)
5 
6character["Humanoid"].Died:Connect(function()
7    local CloneMe = game.ServerStorage.ClassLoadout:Clone()
8    CloneMe.Parent = plr.PlayerGui
9end)
Log in to vote
0
Answered by
harstud 218 Moderation Voter
5 years ago

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.

Answer this question