local player = game.Players.LocalPlayer
local PetGui = game.ReplicatedStorage.PetGui
local stats = player:WaitForChild("leaderstats")
player.character.Humanoid.Died:connect(function()
player.leaderstats.Deaths.Value = player.leaderstats.Deaths.Value +1
player.RespawnLocation = workspace.Checkpoints[tostring(stats.Stage.Value)]
if player.leaderstatsP.FirePet.Value == 1 then
player.leaderstatsP.FirePet.Value = 2
player.PlayerGui.PetGui:Destroy()
game.StarterGui.PetGui:Destroy()
local clone = PetGui:Clone()
clone.Parent = game.StarterGui
local clone2 = PetGui:Clone()
clone2.Parent = player.PlayerGui
if player.PlayerGui.ShopGui.Enabled == true then
player.PlayerGui.PetGui.Enabled = true
game.StarterGui.PetGui.Enabled = true
end
end
end)
local player = game.Players.LocalPlayer
local PetGui = game.ReplicatedStorage.PetGui
local stats = player:WaitForChild("leaderstats")
player.character.Humanoid.Died:connect(function()
player.leaderstats.Deaths.Value = player.leaderstats.Deaths.Value +1
player.RespawnLocation = workspace.Checkpoints[tostring(stats.Stage.Value)]
if player.leaderstatsP.FirePet.Value == 1 then
player.leaderstatsP.FirePet.Value = 2
player.PlayerGui.PetGui:Destroy()
game.StarterGui.PetGui:Destroy()
local clone = PetGui:Clone()
clone.Parent = game.StarterGui
local clone2 = PetGui:Clone()
clone2.Parent = player.PlayerGui
if player.PlayerGui.ShopGui.Enabled == true then
player.PlayerGui.PetGui.Enabled = true
game.StarterGui.PetGui.Enabled = true
end
end
end)
You should probably add this into a characteradded function so it updates the character and doesnt only work the first time the player dies.
local player = game.Players.LocalPlayer
local PetGui = game.ReplicatedStorage.PetGui
local stats = player:WaitForChild("leaderstats")
player.CharacterAdded:Connect(function(char)
char:WaitForChild("Humanoid").Died:connect(function()
player.leaderstats.Deaths.Value = player.leaderstats.Deaths.Value +1
player.RespawnLocation = workspace.Checkpoints[tostring(stats.Stage.Value)]
if player.leaderstatsP.FirePet.Value == 1 then
player.leaderstatsP.FirePet.Value = 2
player.PlayerGui.PetGui:Destroy()
game.StarterGui.PetGui:Destroy()
local clone = PetGui:Clone()
clone.Parent = game.StarterGui
local clone2 = PetGui:Clone()
clone2.Parent = player.PlayerGui
if player.PlayerGui.ShopGui.Enabled == true then
player.PlayerGui.PetGui.Enabled = true
game.StarterGui.PetGui.Enabled = true
end
end
end)
end)
Edit: nvm, you said you put it in StarterCharacterScripts.
Here’s an example of a script in server script service of moving a player’s spawn location Player | Roblox Creator Documentation (at the bottom of the page)