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

How do I respawn the player without adding up a death counter?

Asked by 5 years ago

So I have a script for changing teams in a GUI, it looks like this.

function Click(mouse)
script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Institutional white")

script.Parent.Parent.Parent:Destroy() --destroys the IntroGUI
local StarterGui = Game:GetService('StarterGui')
StarterGui:SetCoreGuiEnabled (Enum.CoreGuiType.PlayerList, true) --enables playerlist
StarterGui:SetCoreGuiEnabled (Enum.CoreGuiType.Backpack, true) --enabled backpack
game.Lighting.Blur.Size = 0 --disabled the blur
game.Players.LocalPlayer.Character.Humanoid.Health = 0 --kills player so they go to their spawn
end


script.Parent.MouseButton1Down:connect(Click)

Now it works fine but not perfect, such as, this game has a death counter and doing

game.Players.LocalPlayer.Character.Humanoid.Health = 0

of course kills them, adding up to the death counter, Ive tried

game.Players.LocalPlayer:LoadCharacter()

instead of

game.Players.LocalPlayer.Character.Humanoid.Health = 0

But it doesnt work in-game with Filtering Enabled.

1 answer

Log in to vote
0
Answered by 5 years ago

Here's a very simple solution... After you reset the character, make the death count's value 1 less... So if they had 2 deaths, and you reset them, the value would be 3, but you would subtract their deaths my 1... So you would still have 2 deaths, I have only tested this in studio, but it seems to work fine

Ad

Answer this question