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.
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