Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables
- local player = game.Players.LocalPlayer
- local teleportDuration = 2
- local gui
- -- Function to create the GUI
- local function createGUI()
- -- Create ScreenGui and MainFrame
- gui = Instance.new("ScreenGui")
- gui.Name = "TeleportGUI"
- gui.ResetOnSpawn = false -- Ensures GUI stays after death
- gui.Parent = player:WaitForChild("PlayerGui")
- local mainFrame = Instance.new("Frame")
- mainFrame.Size = UDim2.new(0, 200, 0, 150)
- mainFrame.Position = UDim2.new(0.5, -100, 0.5, -75)
- mainFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 255) -- Blue
- mainFrame.Active = true
- mainFrame.Draggable = true
- mainFrame.Parent = gui
- -- Close Button (Red 'X')
- local closeButton = Instance.new("TextButton")
- closeButton.Size = UDim2.new(0, 20, 0, 20)
- closeButton.Position = UDim2.new(1, -25, 0, 5)
- closeButton.Text = "X"
- closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- closeButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0) -- Red
- closeButton.Parent = mainFrame
- -- Minimize Button (Dark Blue '-')
- local minimizeButton = Instance.new("TextButton")
- minimizeButton.Size = UDim2.new(0, 20, 0, 20)
- minimizeButton.Position = UDim2.new(1, -50, 0, 5)
- minimizeButton.Text = "-"
- minimizeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- minimizeButton.BackgroundColor3 = Color3.fromRGB(0, 0, 128) -- Dark Blue
- minimizeButton.Parent = mainFrame
- -- Hidden "Open" Button
- local openButton = Instance.new("TextButton")
- openButton.Size = UDim2.new(0, 50, 0, 20)
- openButton.Position = UDim2.new(1, -55, 0, 5)
- openButton.Text = "Open"
- openButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- openButton.BackgroundColor3 = Color3.fromRGB(0, 0, 255) -- Blue
- openButton.Visible = false
- openButton.Active = true
- openButton.Draggable = true
- openButton.Parent = gui
- -- Small Text "Bring TSBG" (Black)
- local bringLabel = Instance.new("TextLabel")
- bringLabel.Size = UDim2.new(0, 60, 0, 20)
- bringLabel.Position = UDim2.new(0, 5, 0, 5)
- bringLabel.Text = "Bring TSBG"
- bringLabel.TextSize = 8
- bringLabel.TextColor3 = Color3.fromRGB(0, 0, 0)
- bringLabel.BackgroundTransparency = 1
- bringLabel.Parent = mainFrame
- -- TextBox for Username/Displayname Input (Dark Blue)
- local targetTextBox = Instance.new("TextBox")
- targetTextBox.Size = UDim2.new(0.8, 0, 0, 30)
- targetTextBox.Position = UDim2.new(0.1, 0, 0.4, 0)
- targetTextBox.PlaceholderText = "Enter Username/Displayname"
- targetTextBox.TextColor3 = Color3.fromRGB(255, 255, 255) -- White text
- targetTextBox.BackgroundColor3 = Color3.fromRGB(0, 0, 128) -- Dark Blue
- targetTextBox.Parent = mainFrame
- -- Bring Button (Dark Blue)
- local bringButton = Instance.new("TextButton")
- bringButton.Size = UDim2.new(0.8, 0, 0, 30)
- bringButton.Position = UDim2.new(0.1, 0, 0.7, 0)
- bringButton.Text = "Bring"
- bringButton.TextColor3 = Color3.fromRGB(255, 255, 255) -- White text
- bringButton.BackgroundColor3 = Color3.fromRGB(0, 0, 128) -- Dark Blue
- bringButton.Parent = mainFrame
- -- Footer Text "by Pyst" (Black)
- local footerLabel = Instance.new("TextLabel")
- footerLabel.Size = UDim2.new(0, 50, 0, 20)
- footerLabel.Position = UDim2.new(0, 5, 1, -25)
- footerLabel.Text = "by Pyst"
- footerLabel.TextSize = 8
- footerLabel.TextColor3 = Color3.fromRGB(0, 0, 0)
- footerLabel.BackgroundTransparency = 1
- footerLabel.Parent = mainFrame
- -- Function to equip the first tool that is in the hotbar (under the screen)
- local function equipFirstHotbarTool()
- -- The first tool equipped in the hotbar is the tool that the player has selected
- local hotbarTool = player.Character and player.Character:FindFirstChildOfClass("Tool")
- if hotbarTool then
- hotbarTool.Parent = player.Character
- end
- end
- -- Button Functionality
- closeButton.MouseButton1Click:Connect(function()
- gui:Destroy()
- end)
- minimizeButton.MouseButton1Click:Connect(function()
- mainFrame.Visible = false
- openButton.Visible = true
- end)
- openButton.MouseButton1Click:Connect(function()
- mainFrame.Visible = true
- openButton.Visible = false
- end)
- bringButton.MouseButton1Click:Connect(function()
- local targetName = targetTextBox.Text
- if targetName == "" then return end
- -- Equip the first tool that is in the hotbar (the tool under the screen)
- equipFirstHotbarTool()
- -- Find target by partial username or display name
- local targetPlayer
- for _, p in pairs(game.Players:GetPlayers()) do
- if string.find(p.Name:lower(), targetName:lower()) or string.find(p.DisplayName:lower(), targetName:lower()) then
- targetPlayer = p
- break
- end
- end
- if targetPlayer then
- local targetChar = targetPlayer.Character
- local myChar = player.Character
- if targetChar and myChar then
- local myPosition = myChar.PrimaryPart.Position -- Store original position
- -- Follow behind target
- local followConnection
- followConnection = game:GetService("RunService").RenderStepped:Connect(function()
- if not targetChar or not myChar then
- followConnection:Disconnect()
- return
- end
- myChar:SetPrimaryPartCFrame(targetChar.PrimaryPart.CFrame * CFrame.new(0, 0, 3))
- end)
- -- Stop following after the specified duration
- wait(teleportDuration)
- followConnection:Disconnect()
- myChar:SetPrimaryPartCFrame(CFrame.new(myPosition)) -- Return to original position
- end
- end
- end)
- end
- -- Initialize the GUI
- createGUI()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement