I am making a admin panel, and in the admin panel there are buttons that let you teleport places. This worked for a little while but I was testing it one day, and it didn’t work correctly after the player died and respawned.
Local Script
local player = game.Players.LocalPlayer
local character = player.Character
local PawnshopTPLocation = game.Workspace:WaitForChild("PawnshopTPLocation")
script.Parent.MouseButton1Click:Connect(function()
character.Head.CFrame = CFrame.new(PawnshopTPLocation.Position)
end)
I’ve tested your code in studio and in a live game and it works. Do you have ResetOnSpawn set to true on the ScreenGui as that could be causing the issue?
For those who are curious, I fixed it by taking the variables outside of the MouseButton1Click and put them inside so that when the player respawns and when they click it runs through the variables again.
Like this:
script.Parent.MouseButton1Click:Connect(function()
------- Variables
local player = game.Players.LocalPlayer
local character = player.Character
local PawnshopTPLocation = game.Workspace:WaitForChild("PawnshopTPLocation")
------- Variables
end)