local behindOffset = 125
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local oldGui = playerGui:FindFirstChild("TeleportDropdownUI")
if oldGui then
oldGui:Destroy()
end
local selectedTarget = nil
local running = false
local unloaded = false
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "TeleportDropdownUI"
screenGui.ResetOnSpawn = false
screenGui.Parent = playerGui
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 260, 0, 280)
frame.Position = UDim2.new(0, 20, 0, 120)
frame.BackgroundColor3 = Color3.fromRGB(30, 30, 35)
frame.BorderSizePixel = 0
frame.Parent = screenGui
local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, -40, 0, 38)
title.Position = UDim2.new(0, 0, 0, 0)
title.BackgroundTransparency = 1
title.Text = "Select Target Player"
title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.Font = Enum.Font.GothamBold
title.TextSize = 16
title.Active = true
title.Parent = frame
local unloadButton = Instance.new("TextButton")
unloadButton.Size = UDim2.new(0, 32, 0, 32)
unloadButton.Position = UDim2.new(1, -36, 0, 3)
unloadButton.BackgroundColor3 = Color3.fromRGB(140, 55, 55)
unloadButton.TextColor3 = Color3.fromRGB(255, 255, 255)
unloadButton.Font = Enum.Font.GothamBold
unloadButton.TextSize = 16
unloadButton.Text = "X"
unloadButton.Parent = frame
local dropdownButton = Instance.new("TextButton")
dropdownButton.Size = UDim2.new(1, -20, 0, 35)
dropdownButton.Position = UDim2.new(0, 10, 0, 48)
dropdownButton.BackgroundColor3 = Color3.fromRGB(50, 50, 60)
dropdownButton.TextColor3 = Color3.fromRGB(255, 255, 255)
dropdownButton.Font = Enum.Font.Gotham
dropdownButton.TextSize = 14
dropdownButton.Text = "Choose player"
dropdownButton.Parent = frame
local dropdownList = Instance.new("ScrollingFrame")
dropdownList.Size = UDim2.new(1, -20, 0, 0)
dropdownList.Position = UDim2.new(0, 10, 0, 88)
dropdownList.BackgroundColor3 = Color3.fromRGB(40, 40, 48)
dropdownList.BorderSizePixel = 0
dropdownList.CanvasSize = UDim2.new(0, 0, 0, 0)
dropdownList.ScrollBarThickness = 4
dropdownList.Visible = false
dropdownList.Parent = frame
local listLayout = Instance.new("UIListLayout")
listLayout.Parent = dropdownList
local distanceLabel = Instance.new("TextLabel")
distanceLabel.Size = UDim2.new(0, 95, 0, 35)
distanceLabel.Position = UDim2.new(0, 10, 0, 190)
distanceLabel.BackgroundTransparency = 1
distanceLabel.Text = "Distance"
distanceLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
distanceLabel.Font = Enum.Font.GothamBold
distanceLabel.TextSize = 14
distanceLabel.TextXAlignment = Enum.TextXAlignment.Left
distanceLabel.Parent = frame
local distanceBox = Instance.new("TextBox")
distanceBox.Size = UDim2.new(0, 135, 0, 35)
distanceBox.Position = UDim2.new(1, -145, 0, 190)
distanceBox.BackgroundColor3 = Color3.fromRGB(50, 50, 60)
distanceBox.TextColor3 = Color3.fromRGB(255, 255, 255)
distanceBox.Font = Enum.Font.Gotham
distanceBox.TextSize = 14
distanceBox.Text = tostring(behindOffset)
distanceBox.ClearTextOnFocus = false
distanceBox.Parent = frame
local startButton = Instance.new("TextButton")
startButton.Size = UDim2.new(1, -20, 0, 35)
startButton.Position = UDim2.new(0, 10, 1, -45)
startButton.BackgroundColor3 = Color3.fromRGB(70, 130, 90)
startButton.TextColor3 = Color3.fromRGB(255, 255, 255)
startButton.Font = Enum.Font.GothamBold
startButton.TextSize = 14
startButton.Text = "Start"
startButton.Parent = frame
local function getRoot(character)
return character and character:FindFirstChild("HumanoidRootPart")
end
local function stopTeleport()
running = false
if not unloaded then
startButton.Text = "Start"
startButton.BackgroundColor3 = Color3.fromRGB(70, 130, 90)
end
end
local function unloadMenu()
unloaded = true
running = false
if screenGui then
screenGui:Destroy()
end
end
-- Dragging
local dragging = false
local dragInput = nil
local dragStart = nil
local startPos = nil
local function updateDrag(input)
local delta = input.Position - dragStart
frame.Position = UDim2.new(
startPos.X.Scale,
startPos.X.Offset + delta.X,
startPos.Y.Scale,
startPos.Y.Offset + delta.Y
)
end
title.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPos = frame.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
title.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
dragInput = input
end
end)
UserInputService.InputChanged:Connect(function(input)
if dragging and input == dragInput and not unloaded then
updateDrag(input)
end
end)
local function refreshDropdown()
for _, child in ipairs(dropdownList:GetChildren()) do
if child:IsA("TextButton") then
child:Destroy()
end
end
local count = 0
for _, targetPlayer in ipairs(Players:GetPlayers()) do
if targetPlayer ~= player then
count += 1
local option = Instance.new("TextButton")
option.Size = UDim2.new(1, 0, 0, 30)
option.BackgroundColor3 = Color3.fromRGB(55, 55, 65)
option.TextColor3 = Color3.fromRGB(255, 255, 255)
option.Font = Enum.Font.Gotham
option.TextSize = 14
option.Text = targetPlayer.Name
option.Parent = dropdownList
option.MouseButton1Click:Connect(function()
selectedTarget = targetPlayer.Name
dropdownButton.Text = targetPlayer.Name
dropdownList.Visible = false
dropdownList.Size = UDim2.new(1, -20, 0, 0)
end)
end
end
dropdownList.CanvasSize = UDim2.new(0, 0, 0, count * 30)
end
local function startTeleport()
if running or not selectedTarget then
return
end
running = true
startButton.Text = "Stop"
startButton.BackgroundColor3 = Color3.fromRGB(150, 70, 70)
task.spawn(function()
local stableTime = 0
local lastTeleportPos = nil
while running and not unloaded do
local targetPlayer = Players:FindFirstChild(selectedTarget)
local myRoot = getRoot(player.Character)
local targetRoot = targetPlayer and getRoot(targetPlayer.Character)
if not myRoot or not targetRoot then
task.wait(0.1)
continue
end
if lastTeleportPos then
local myRootPos = myRoot.Position
local teleportCheck =
math.abs(myRootPos.X - lastTeleportPos.X) >= 100 or
math.abs(myRootPos.Y - lastTeleportPos.Y) >= 100 or
math.abs(myRootPos.Z - lastTeleportPos.Z) >= 100
if teleportCheck then
stableTime = 0
else
stableTime += 0.09
if stableTime >= 1.0 then
break
end
end
end
myRoot.CFrame = targetRoot.CFrame * CFrame.new(0, 0, behindOffset)
lastTeleportPos = myRoot.Position
task.wait(0.09)
end
stopTeleport()
end)
end
distanceBox.FocusLost:Connect(function()
local newDistance = tonumber(distanceBox.Text)
if newDistance then
behindOffset = newDistance
end
distanceBox.Text = tostring(behindOffset)
end)
dropdownButton.MouseButton1Click:Connect(function()
refreshDropdown()
dropdownList.Visible = not dropdownList.Visible
dropdownList.Size = dropdownList.Visible
and UDim2.new(1, -20, 0, 90)
or UDim2.new(1, -20, 0, 0)
end)
startButton.MouseButton1Click:Connect(function()
if running then
stopTeleport()
else
startTeleport()
end
end)
unloadButton.MouseButton1Click:Connect(unloadMenu)
Players.PlayerAdded:Connect(refreshDropdown)
Players.PlayerRemoving:Connect(function(leavingPlayer)
if selectedTarget == leavingPlayer.Name then
selectedTarget = nil
dropdownButton.Text = "Choose player"
stopTeleport()
end
refreshDropdown()
end)
refreshDropdown()
Comments
No comments yet
Be the first to share your thoughts!