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

How can I have someone click a gui button and have them respawn?

script.Parent.MouseButton1Click:connect(function()
	game.Players.LocalPlayer.CharacterAppearanceId = 149574052
	local Pos = game.Players.LocalPlayer.Character:GetPrimaryPartCFrame()
	game.Players.LocalPlayer:LoadCharacter()
	game.Players.LocalPlayer.Character:SetPrimaryPartCFrame(Pos)
	if game.Players.LocalPlayer.Character:FindFirstChild("ForceField") then
		game.Players.LocalPlayer.Character["ForceField"]:Destroy()
	end
end)

I want them to click a ImageButton and it puts them as the player id I choose then it respawns them, i got it working but only in studio and it said something about the back end server in output and dev console

5 comments

0

Make sure the script is a LocalScript.

1

And can you paste down your script, so I can see?

0

Provide the error

0

Hit Edit Question and format your code in Lua Code block

0

What is the error?

1 answer

First of all, make sure the script is in a LocalScript. Second of all, if you want to make the player respawn, then why don't you just kill the player? Third of all, you were setting the player PrimaryPartCFrame to where it is currently standing (I think). Fourth of all, I haven't test out the script below.

script.Parent.MouseButton1Click:connect(function()
	game.Players.LocalPlayer.CharacterAppearanceId = 149574052
	game.Players.LocalPlayer:LoadCharacter()

	game.Players.LocalPlayer.Character:SetPrimaryPartCFrame(0, 1, 0) -- Origin of X, Y, Z (Well kinda)

	if game.Players.LocalPlayer.Character:FindFirstChild("ForceField") then
		game.Players.LocalPlayer.Character["ForceField"]:Destroy()
	end
end)

3 comments

0

You can still make players respawn with :LoadCharacter(). Both ways work.

0

Oh well...

0

Still says the same error

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