
Key RequiredUniversal

-- Create ScreenGui
local ScreenGui = Instance.new("ScreenGui")
local MainFrame = Instance.new("Frame")
local Title = Instance.new("TextLabel")
local ToggleButton = Instance.new("TextButton")
local DistanceTextBox = Instance.new("TextBox")
local DestroyButton = Instance.new("TextButton")
local HideShowButton = Instance.new("TextButton")
-- Rainbow Border Frame (The Glow Outline)
local BorderFrame = Instance.new("Frame")
BorderFrame.Name = "BorderFrame"
BorderFrame.Parent = ScreenGui
BorderFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
BorderFrame.Position = UDim2.new(0.5, -112, 0.5, -107)
BorderFrame.Size = UDim2.new(0, 224, 0, 214)
BorderFrame.BorderSizePixel = 0
BorderFrame.Active = true
-- Properties for ScreenGui
ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
ScreenGui.ResetOnSpawn = false
ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
-- Nest MainFrame inside the BorderFrame
MainFrame.Name = "MainFrame"
MainFrame.Parent = BorderFrame
MainFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
MainFrame.Position = UDim2.new(0, 2, 0, 2)
MainFrame.Size = UDim2.new(0, 220, 0, 210)
MainFrame.BorderSizePixel = 0
-- UI Corner Radii
local function addCorners(instance, radius)
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, radius)
corner.Parent = instance
end
addCorners(BorderFrame, 10)
addCorners(MainFrame, 8)
-- Properties for Title
Title.Name = "Title"
Title.Parent = MainFrame
Title.BackgroundColor3 = Color3.fromRGB(15, 15, 15)
Title.Size = UDim2.new(1, 0, 0, 35)
Title.Font = Enum.Font.GothamBold
Title.Text = "attach behind script"
Title.TextColor3 = Color3.fromRGB(255, 255, 255)
Title.TextSize = 14
addCorners(Title, 8)
-- Properties for Button 1 (Toggle Attach)
ToggleButton.Name = "ToggleButton"
ToggleButton.Parent = MainFrame
ToggleButton.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
ToggleButton.Position = UDim2.new(0, 10, 0, 50)
ToggleButton.Size = UDim2.new(1, -20, 0, 38)
ToggleButton.Font = Enum.Font.GothamSemibold
ToggleButton.Text = "Attach: Disabled"
ToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
ToggleButton.TextSize = 13
addCorners(ToggleButton, 6)
-- Properties for TextBox (Distance Input Box)
DistanceTextBox.Name = "DistanceTextBox"
DistanceTextBox.Parent = MainFrame
DistanceTextBox.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
DistanceTextBox.Position = UDim2.new(0, 10, 0, 100)
DistanceTextBox.Size = UDim2.new(1, -20, 0, 38)
DistanceTextBox.Font = Enum.Font.GothamSemibold
DistanceTextBox.Text = "Distance: 3"
DistanceTextBox.PlaceholderText = "Tap to type distance..."
DistanceTextBox.TextColor3 = Color3.fromRGB(255, 255, 255)
DistanceTextBox.TextSize = 13
DistanceTextBox.ClearTextOnFocus = false
addCorners(DistanceTextBox, 6)
-- Properties for Button 3 (Destroy GUI)
DestroyButton.Name = "DestroyButton"
DestroyButton.Parent = MainFrame
DestroyButton.BackgroundColor3 = Color3.fromRGB(180, 45, 45)
DestroyButton.Position = UDim2.new(0, 10, 0, 150)
DestroyButton.Size = UDim2.new(1, -20, 0, 38)
DestroyButton.Font = Enum.Font.GothamBold
DestroyButton.Text = "Destroy GUI"
DestroyButton.TextColor3 = Color3.fromRGB(255, 255, 255)
DestroyButton.TextSize = 13
addCorners(DestroyButton, 6)
-- Properties for Hide/Show Button (Moved right under the Roblox Core Menu Logo)
HideShowButton.Name = "HideShowButton"
HideShowButton.Parent = ScreenGui
HideShowButton.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
-- 15 pixels from left side, 55 pixels down from the very top (safely clear of top-left core elements)
HideShowButton.Position = UDim2.new(0, 15, 0, 55)
HideShowButton.Size = UDim2.new(0, 90, 0, 35)
HideShowButton.Font = Enum.Font.GothamBold
HideShowButton.Text = "Hide/Show"
HideShowButton.TextColor3 = Color3.fromRGB(255, 255, 255)
HideShowButton.TextSize = 12
HideShowButton.Active = true
addCorners(HideShowButton, 6)
-- Dragging Functionality Variables
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local LocalPlayer = Players.LocalPlayer
local function makeDraggable(frame)
local dragging, dragInput, dragStart, startPos
frame.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)
frame.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 input == dragInput and dragging then
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
end)
end
makeDraggable(BorderFrame)
makeDraggable(HideShowButton)
-- Attach System Variables
local attachEnabled = false
local attachDistance = 3
local loopConnection = nil
-- Function to find the nearest player
local function getNearestPlayer()
local nearestPlayer = nil
local shortestDistance = math.huge
local myChar = LocalPlayer.Character
if not myChar or not myChar:FindFirstChild("HumanoidRootPart") then return nil end
local myHrp = myChar.HumanoidRootPart
for _, player in pairs(Players:GetPlayers()) do
if player ~= LocalPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
local targetHrp = player.Character.HumanoidRootPart
local distance = (myHrp.Position - targetHrp.Position).Magnitude
if distance < shortestDistance then
shortestDistance = distance
nearestPlayer = player
end
end
end
return nearestPlayer
end
-- Teleport and Orientation Loop & Rainbow Effect Loop
local function startLoops()
loopConnection = RunService.Heartbeat:Connect(function()
-- Animated Rainbow Line Effect
local hue = (tick() % 4) / 4
local rainbowColor = Color3.fromHSV(hue, 1, 1)
BorderFrame.BackgroundColor3 = rainbowColor
-- Behind Attachment Mechanic
if not attachEnabled then return end
local myChar = LocalPlayer.Character
if not myChar or not myChar:FindFirstChild("HumanoidRootPart") then return end
local targetPlayer = getNearestPlayer()
if targetPlayer and targetPlayer.Character and targetPlayer.Character:FindFirstChild("HumanoidRootPart") then
local targetHrp = targetPlayer.Character.HumanoidRootPart
local targetLookVector = targetHrp.CFrame.LookVector
local behindPosition = targetHrp.Position - (targetLookVector * attachDistance)
myChar.HumanoidRootPart.CFrame = CFrame.new(behindPosition, behindPosition + targetLookVector)
end
end)
end
startLoops()
-- Button Action 1: Toggle Attach
ToggleButton.MouseButton1Click:Connect(function()
attachEnabled = not attachEnabled
if attachEnabled then
ToggleButton.Text = "Attach: Enabled"
ToggleButton.BackgroundColor3 = Color3.fromRGB(45, 140, 45)
else
ToggleButton.Text = "Attach: Disabled"
ToggleButton.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
end
end)
-- Mobile clear text box logic
DistanceTextBox.Focused:Connect(function()
DistanceTextBox.Text = ""
end)
-- Finish mobile keyboard capture
DistanceTextBox.FocusLost:Connect(function(enterPressed)
local num = tonumber(DistanceTextBox.Text)
if num then
attachDistance = num
end
DistanceTextBox.Text = "Distance: " .. tostring(attachDistance)
end)
-- Button Action 3: Destroy GUI
DestroyButton.MouseButton1Click:Connect(function()
attachEnabled = false
if loopConnection then loopConnection:Disconnect() end
ScreenGui:Destroy()
end)
-- Hide/Show Toggle Functionality
HideShowButton.MouseButton1Click:Connect(function()
BorderFrame.Visible = not BorderFrame.Visible
end)No comments yet for this script.



