How can i make a gui that resets the player and teleports them?

Hello, I am trying to make a gui that resets the player and teleports them, but I can’t figure out how to do it. I have made a TP script and tried to combine it with a player reset script, but it doesnt work. There are no errors. Thanks in advance.

edit: I forgot to put the code of the gui button (This is a local script):

local db = true
local player = game.Players.LocalPlayer
local target = game.Workspace.Tpspawn
local delay = 3

script.Parent.MouseButton1Click:connect(function()
if db == true then
db = false
player.Character.HumanoidRootPart.CFrame = target.CFrame * CFrame.new(0, 3, 0)

	for i = delay, 1, -1 do
		script.Parent.Text = i
		wait(1)
	end
	script.Parent.Text = "Teleport to the Hut"
	db = true
end

end)

This script only teleports the player when clicked and has a 3 second cooldown. I’m trying to make it to where it resets the player and then they either teleport or respawn at the target.

You Mean to Make A Button, Which when The Player Click, He Gets
Teleported to Where?

Do you mean reset as in respawn?
By the way, mind sending some of the code?

Hey, sorry for the late reply. I have edited the original topic to explain my problem in more detail.

You cannot reset the character client-sided. Create a remote event that gets fired when the button is pressed, and then the server can do the work.

To reset them, do Player:LoadCharacter() and then set the HumanoidRootPart CFrame

now im getting an error saying: LoadCharacter can only be called by the backend server (line 11)

Here is the local script now:

local db = true
local player = game.Players.LocalPlayer
local target = game.Workspace.Tpspawn
local delay = 3
local remoteEvent = game.ReplicatedStorage:WaitForChild(“RemoteEvent”)

script.Parent.MouseButton1Click:connect(function()
if db == true then
db = false
remoteEvent:FireServer()
player:LoadCharacter()
player.Character.HumanoidRootPart.CFrame = target.CFrame * CFrame.new(0, 3, 0)

	for i = delay, 1, -1 do
		script.Parent.Text = i
		wait(1)
	end
	script.Parent.Text = "Teleport to the Hut"
	db = true
end

end)

You don’t need to do LoadCharacter() after firing the event, just have a server script in ServerSciptService

remoteEvent.OnServerEvent:Connect(function(player)
     player:LoadCharacter()
end)
1 Like

Thank you, this works great! ‎

No problem! Always happy to help :slight_smile: