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

Is there a way to respawn a player without killing them?

Asked by
P100D 590 Moderation Voter
9 years ago

I want a way to quickly and easily respawn players, without messing with their KDR. Is there a function to do this, or should I just use CFrame?

2 answers

Log in to vote
3
Answered by 9 years ago

Yes, there is a really simple way to do so. Sadly, it only works through server scripts. There is a function of the player, called LoadCharacter

Example:

-- server script
Player:LoadCharacter()

That's pretty much it.

0
Thanks for the answer! You mentioned that using "Player:LoadCharacter" would only work in a server script. Do you mean a script running in ServerScriptService, or just a regular script as opposed to LocalScript? P100D 590 — 9y
0
Any script that isn't a LocalScript. Vlatkovski 320 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

yes, there is! you will need a GUI! If the player pressed the button they will respawn (with killing) and then dicrease the Death or WOs value by 1!

else you have to use a CFrame

okay, here is the script (please make a Gui for that)

Button = script.Parent              --insert the Button in the Menu inside the screenGui which parent is StarterGui (put the script in here)
Menu = script.Parent.Parent   --insert the Menu in a ScreenGui


Button.MouseButton1Down:connect(function()
    script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0
    script.Parent.Parent.Parent.Parent.Parent.leaderstats.Deaths.Value = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Deaths.Value - 1
end)

Change Deaths to WOs if you want!

script.Parent.Parent.Parent.Parent.Parent this let the script (just a normal script) look to game.Players.LocalPlayer

game.Players.LocalPlayers can only be used in a "LocalScript" But many people like normal scripts most..

If you want to use a CFrame use this: btw, I didn't tested this but just typed it in here, if it doesn't work please tell me :( don't give me a -1

local Spawn = game.Workspace.SpawnBrick --Edit to your spawn!
Button = script.Parent              --insert the Button in the Menu inside the screenGui which parent is StarterGui (put the script in here)
Menu = script.Parent.Parent   --insert the Menu in a ScreenGui

Button.MouseButton1Down:connect(function()
    script.Parent.Parent.Parent.Parent.Parent.Character.Position = CFrame.new(Spawn.Postition)
end)

Answer this question