Attachment script
Key RequiredUniversal

Attachment script

Universal ScriptDev_SiddhartDev_Siddhart 391 views 2.6K executesUpdated Sep 5, 2026
Unrated
00
Lua Script•357 lines (12132 chars)
--[[ 
    ================================================================
    |  SIDDHARTH HIGH-PRECISION PLAYER ATTACH GUI SYSTEM (LUAU)   |
    |  Author: Siddharth                                           |
    |  Version: 2.5.0                                              |
    |  Description: Full Client-Side UI & Player Tracking Engine  |
    ================================================================
--]]

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")

local localPlayer = Players.LocalPlayer

--------------------------------------------------------------------
-- 1. DYNAMIC GUI CREATION (Auto Generated Layout)
--------------------------------------------------------------------
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "SiddharthAttachGui"
screenGui.ResetOnSpawn = false
screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling

-- Toggle Button (Always Visible)
local toggleButton = Instance.new("TextButton")
toggleButton.Name = "ToggleButton"
toggleButton.Size = UDim2.new(0, 140, 0, 45)
toggleButton.Position = UDim2.new(0, 20, 0.5, -22)
toggleButton.BackgroundColor3 = Color3.fromRGB(24, 28, 36)
toggleButton.BorderSizePixel = 0
toggleButton.Text = "TOGGLE GUI"
toggleButton.TextColor3 = Color3.fromRGB(0, 230, 180)
toggleButton.TextSize = 14
toggleButton.Font = Enum.Font.GothamBold
toggleButton.Parent = screenGui

local toggleCorner = Instance.new("UICorner")
toggleCorner.CornerRadius = UDim.new(0, 8)
toggleCorner.Parent = toggleButton

local toggleStroke = Instance.new("UIStroke")
toggleStroke.Color = Color3.fromRGB(0, 230, 180)
toggleStroke.Thickness = 1.5
toggleStroke.Parent = toggleButton

-- Main Container Frame
local mainFrame = Instance.new("Frame")
mainFrame.Name = "MainFrame"
mainFrame.Size = UDim2.new(0, 420, 0, 380)
mainFrame.Position = UDim2.new(0.5, -210, 0.5, -190)
mainFrame.BackgroundColor3 = Color3.fromRGB(15, 18, 24)
mainFrame.BorderSizePixel = 0
mainFrame.ClipsDescendants = true
mainFrame.Parent = screenGui

local frameCorner = Instance.new("UICorner")
frameCorner.CornerRadius = UDim.new(0, 12)
frameCorner.Parent = mainFrame

local frameStroke = Instance.new("UIStroke")
frameStroke.Color = Color3.fromRGB(40, 48, 62)
frameStroke.Thickness = 2
frameStroke.Parent = mainFrame

-- Title Banner Header (Made by Siddharth)
local headerFrame = Instance.new("Frame")
headerFrame.Name = "Header"
headerFrame.Size = UDim2.new(1, 0, 0, 50)
headerFrame.BackgroundColor3 = Color3.fromRGB(22, 27, 36)
headerFrame.BorderSizePixel = 0
headerFrame.Parent = mainFrame

local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, -20, 1, 0)
titleLabel.Position = UDim2.new(0, 15, 0, 0)
titleLabel.BackgroundTransparency = 1
titleLabel.Text = "ATTACH HUB | Made by Siddharth"
titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
titleLabel.TextSize = 15
titleLabel.Font = Enum.Font.GothamBold
titleLabel.TextXAlignment = Enum.TextXAlignment.Left
titleLabel.Parent = headerFrame

-- Status Label
local statusLabel = Instance.new("TextLabel")
statusLabel.Size = UDim2.new(1, -30, 0, 20)
statusLabel.Position = UDim2.new(0, 15, 0, 58)
statusLabel.BackgroundTransparency = 1
statusLabel.Text = "Status: IDLE"
statusLabel.TextColor3 = Color3.fromRGB(160, 175, 200)
statusLabel.TextSize = 12
statusLabel.Font = Enum.Font.Gotham
statusLabel.TextXAlignment = Enum.TextXAlignment.Left
statusLabel.Parent = mainFrame

-- Target Player Input Box
local playerBoxLabel = Instance.new("TextLabel")
playerBoxLabel.Size = UDim2.new(1, -30, 0, 18)
playerBoxLabel.Position = UDim2.new(0, 15, 0, 88)
playerBoxLabel.BackgroundTransparency = 1
playerBoxLabel.Text = "TARGET PLAYER NAME / DISPLAY NAME:"
playerBoxLabel.TextColor3 = Color3.fromRGB(200, 210, 225)
playerBoxLabel.TextSize = 11
playerBoxLabel.Font = Enum.Font.GothamMedium
playerBoxLabel.TextXAlignment = Enum.TextXAlignment.Left
playerBoxLabel.Parent = mainFrame

local playerTextBox = Instance.new("TextBox")
playerTextBox.Name = "PlayerTextBox"
playerTextBox.Size = UDim2.new(1, -30, 0, 42)
playerTextBox.Position = UDim2.new(0, 15, 0, 110)
playerTextBox.BackgroundColor3 = Color3.fromRGB(24, 30, 40)
playerTextBox.BorderSizePixel = 0
playerTextBox.PlaceholderText = "Enter player name..."
playerTextBox.PlaceholderColor3 = Color3.fromRGB(90, 105, 125)
playerTextBox.Text = ""
playerTextBox.TextColor3 = Color3.fromRGB(255, 255, 255)
playerTextBox.TextSize = 13
playerTextBox.Font = Enum.Font.Gotham
playerTextBox.Parent = mainFrame

local pBoxCorner = Instance.new("UICorner")
pBoxCorner.CornerRadius = UDim.new(0, 8)
pBoxCorner.Parent = playerTextBox

-- Distance Input Box
local distanceBoxLabel = Instance.new("TextLabel")
distanceBoxLabel.Size = UDim2.new(1, -30, 0, 18)
distanceBoxLabel.Position = UDim2.new(0, 15, 0, 162)
distanceBoxLabel.BackgroundTransparency = 1
distanceBoxLabel.Text = "OFFSET DISTANCE (STUDS):"
distanceBoxLabel.TextColor3 = Color3.fromRGB(200, 210, 225)
distanceBoxLabel.TextSize = 11
distanceBoxLabel.Font = Enum.Font.GothamMedium
distanceBoxLabel.TextXAlignment = Enum.TextXAlignment.Left
distanceBoxLabel.Parent = mainFrame

local distanceTextBox = Instance.new("TextBox")
distanceTextBox.Name = "DistanceTextBox"
distanceTextBox.Size = UDim2.new(1, -30, 0, 42)
distanceTextBox.Position = UDim2.new(0, 15, 0, 184)
distanceTextBox.BackgroundColor3 = Color3.fromRGB(24, 30, 40)
distanceTextBox.BorderSizePixel = 0
distanceTextBox.PlaceholderText = "Default: 5 (e.g. 3, 5, 10)"
distanceTextBox.PlaceholderColor3 = Color3.fromRGB(90, 105, 125)
distanceTextBox.Text = "5"
distanceTextBox.TextColor3 = Color3.fromRGB(255, 255, 255)
distanceTextBox.TextSize = 13
distanceTextBox.Font = Enum.Font.Gotham
distanceTextBox.Parent = mainFrame

local dBoxCorner = Instance.new("UICorner")
dBoxCorner.CornerRadius = UDim.new(0, 8)
dBoxCorner.Parent = distanceTextBox

-- Control Buttons
local attachBtn = Instance.new("TextButton")
attachBtn.Name = "AttachBtn"
attachBtn.Size = UDim2.new(0.46, 0, 0, 45)
attachBtn.Position = UDim2.new(0, 15, 0, 246)
attachBtn.BackgroundColor3 = Color3.fromRGB(0, 180, 120)
attachBtn.BorderSizePixel = 0
attachBtn.Text = "START ATTACH"
attachBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
attachBtn.TextSize = 13
attachBtn.Font = Enum.Font.GothamBold
attachBtn.Parent = mainFrame

local aCorner = Instance.new("UICorner")
aCorner.CornerRadius = UDim.new(0, 8)
aCorner.Parent = attachBtn

local detachBtn = Instance.new("TextButton")
detachBtn.Name = "DetachBtn"
detachBtn.Size = UDim2.new(0.46, 0, 0, 45)
detachBtn.Position = UDim2.new(0.54, 0, 0, 246)
detachBtn.BackgroundColor3 = Color3.fromRGB(220, 50, 60)
detachBtn.BorderSizePixel = 0
detachBtn.Text = "STOP ATTACH"
detachBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
detachBtn.TextSize = 13
detachBtn.Font = Enum.Font.GothamBold
detachBtn.Parent = mainFrame

local dCorner = Instance.new("UICorner")
dCorner.CornerRadius = UDim.new(0, 8)
dCorner.Parent = detachBtn

-- Footer Note
local footerLabel = Instance.new("TextLabel")
footerLabel.Size = UDim2.new(1, -30, 0, 25)
footerLabel.Position = UDim2.new(0, 15, 0, 310)
footerLabel.BackgroundTransparency = 1
footerLabel.Text = "System Developed & Configured by Siddharth"
footerLabel.TextColor3 = Color3.fromRGB(100, 115, 135)
footerLabel.TextSize = 10
footerLabel.Font = Enum.Font.Gotham
footerLabel.Parent = mainFrame

-- Parent ScreenGui to PlayerGui
local success, err = pcall(function()
	screenGui.Parent = localPlayer:WaitForChild("PlayerGui")
end)
if not success then
	screenGui.Parent = game:GetService("CoreGui")
end

--------------------------------------------------------------------
-- 2. GUI DRAGGING CONTROLLER
--------------------------------------------------------------------
local dragging, dragInput, dragStart, startPos

local function updateInput(input)
	local delta = input.Position - dragStart
	mainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
end

headerFrame.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
		dragging = true
		dragStart = input.Position
		startPos = mainFrame.Position

		input.Changed:Connect(function()
			if input.UserInputState == Enum.UserInputState.End then
				dragging = false
			end
		end)
	end
end)

headerFrame.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
		updateInput(input)
	end
end)

--------------------------------------------------------------------
-- 3. CORE ATTACH & LOGIC ENGINE
--------------------------------------------------------------------
local isAttached = false
local renderConnection = nil
local currentTargetPlayer = nil

-- UI Toggle Visibility Function
toggleButton.MouseButton1Click:Connect(function()
	mainFrame.Visible = not mainFrame.Visible
	if mainFrame.Visible then
		toggleButton.Text = "CLOSE GUI"
		toggleButton.TextColor3 = Color3.fromRGB(255, 80, 90)
		toggleStroke.Color = Color3.fromRGB(255, 80, 90)
	else
		toggleButton.Text = "OPEN GUI"
		toggleButton.TextColor3 = Color3.fromRGB(0, 230, 180)
		toggleStroke.Color = Color3.fromRGB(0, 230, 180)
	end
end)

-- Target Finder Logic (Supports Partial Names, Usernames & DisplayNames)
local function getTargetPlayer(queryText)
	queryText = string.lower(queryText:gsub("%s+", ""))
	if queryText == "" then return nil end

	for _, p in ipairs(Players:GetPlayers()) do
		if p ~= localPlayer then
			local uName = string.lower(p.Name)
			local dName = string.lower(p.DisplayName)
			
			if uName == queryText or dName == queryText then
				return p
			end
			if string.find(uName, queryText) or string.find(dName, queryText) then
				return p
			end
		end
	end
	return nil
end

-- Detach / Stop Function
local function detach()
	isAttached = false
	if renderConnection then
		renderConnection:Disconnect()
		renderConnection = nil
	end
	currentTargetPlayer = nil
	statusLabel.Text = "Status: IDLE"
	statusLabel.TextColor3 = Color3.fromRGB(160, 175, 200)
end

-- Attach Functionality
local function startAttach()
	local targetQuery = playerTextBox.Text
	local target = getTargetPlayer(targetQuery)

	if not target then
		statusLabel.Text = "Status: ERROR - Player Not Found!"
		statusLabel.TextColor3 = Color3.fromRGB(255, 80, 80)
		return
	end

	local distance = tonumber(distanceTextBox.Text) or 5

	if renderConnection then
		renderConnection:Disconnect()
		renderConnection = nil
	end

	isAttached = true
	currentTargetPlayer = target
	statusLabel.Text = "Status: ATTACHED to " .. target.DisplayName .. " (@" .. target.Name .. ")"
	statusLabel.TextColor3 = Color3.fromRGB(0, 230, 180)

	-- Smooth Frame-by-frame Follow Loop
	renderConnection = RunService.RenderStepped:Connect(function()
		if not isAttached or not currentTargetPlayer then
			detach()
			return
		end

		local myChar = localPlayer.Character
		local targetChar = currentTargetPlayer.Character

		if myChar and targetChar then
			local myHRP = myChar:FindFirstChild("HumanoidRootPart")
			local targetHRP = targetChar:FindFirstChild("HumanoidRootPart")
			local myHumanoid = myChar:FindFirstChildOfClass("Humanoid")

			if myHRP and targetHRP then
				-- Maintains player orientation behind the target player
				myHRP.CFrame = targetHRP.CFrame * CFrame.new(0, 0, distance)
				
				-- Prevents falling/tripping animation glitches while teleporting
				if myHumanoid then
					myHumanoid:ChangeState(Enum.HumanoidStateType.Freefall)
				end
			end
		else
			statusLabel.Text = "Status: Waiting for Character..."
			statusLabel.TextColor3 = Color3.fromRGB(255, 200, 80)
		end
	end)
end

-- Connect Action Events
attachBtn.MouseButton1Click:Connect(startAttach)
detachBtn.MouseButton1Click:Connect(detach)

print("[SUCCESS] Siddharth Attach GUI Engine Loaded Successfully!")

Features & Information

You Can Use This Script With Ur Delta Executor friends And Use Kill Aura with this Script Give me A feed back

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts