So right now i have to hover over a screen gui and click on it so i can teleport to the surface. Any idea how i can convert it to so i can just press a button?
local plr = game.Players.LocalPlayer
local char = plr.Character
repeat wait() until char ~= nil
script.Parent.Surface.MouseButton1Click:Connect(function()
local closestDistance = math.huge
local closestSurface = nil
for _, zone in next, workspace.Map.Zones:GetChildren() do
local surface = zone.Surface
if (char.UpperTorso.Position - surface.Position).Magnitude < closestDistance then
closestDistance = (char.UpperTorso.Position - surface.Position).Magnitude
closestSurface = surface
end
end
char.UpperTorso.CFrame = closestSurface.CFrame
end)