Sword helper
Key RequiredUniversal

Sword helper

Universal ScriptHavensSCPHavensSCP 561 views 19 executesUpdated Mar 30, 2026
Unrated
00
Lua Script•165 lines (3093 chars)
-- tool tracker + beam + box (ghost)

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

local plr = Players.LocalPlayer

local char
local beam, att0, att1
local box
local currentHandle

local RANGE = 25

local function setupBeam()
if beam then beam:Destroy() end

att0 = Instance.new("Attachment")
att1 = Instance.new("Attachment")

beam = Instance.new("Beam")
beam.Attachment0 = att0
beam.Attachment1 = att1
beam.Width0 = 0.1
beam.Width1 = 0.1
beam.FaceCamera = true
beam.Color = ColorSequence.new(Color3.new(1,0,0))

att0.Parent = workspace.Terrain
att1.Parent = workspace.Terrain
beam.Parent = workspace.Terrain

end

local function createBox(part)
if box then box:Destroy() end

currentHandle = part

box = Instance.new("SelectionBox")
box.Adornee = part
box.LineThickness = 0.02
box.Color3 = Color3.fromRGB(255,0,0)
box.SurfaceColor3 = Color3.fromRGB(255,0,0)
box.SurfaceTransparency = 0.8
box.Parent = part

end

local function updateBoxColor(isTouching)
if not box then return end

if isTouching then
box.Color3 = Color3.fromRGB(0,255,0)
box.SurfaceColor3 = Color3.fromRGB(0,255,0)
else
box.Color3 = Color3.fromRGB(255,0,0)
box.SurfaceColor3 = Color3.fromRGB(255,0,0)
end

end

local function getTool()
if not char then return end
for _,v in ipairs(char:GetChildren()) do
if v:IsA("Tool") then
return v
end
end
end

local function getClosestPart()
if not char then return end

local closestPart, dist = nil, RANGE
local origin = char:GetPivot().Position

for _,p in ipairs(Players:GetPlayers()) do
if p ~= plr and p.Character then
for _,part in ipairs(p.Character:GetChildren()) do
if part:IsA("BasePart") then
local d = (part.Position - origin).Magnitude
if d < dist then
dist = d
closestPart = part
end
end
end
end
end

return closestPart

end

local function onCharacter(c)
char = c
setupBeam()

c.ChildAdded:Connect(function(obj)
if obj:IsA("Tool") then
task.wait()
local handle = obj:FindFirstChild("Handle") or obj:FindFirstChildWhichIsA("BasePart")
if handle then
createBox(handle)
end
end
end)

c.ChildRemoved:Connect(function(obj)
if obj:IsA("Tool") then
if box then box:Destroy() end
currentHandle = nil
end
end)

end

plr.CharacterAdded:Connect(onCharacter)
if plr.Character then
onCharacter(plr.Character)
end

RunService.Heartbeat:Connect(function()
if not char then return end

local tool = getTool()
local targetPart = getClosestPart()

if not tool or not targetPart then
if beam then beam.Enabled = false end
updateBoxColor(false)
return
end

local handle = tool:FindFirstChild("Handle") or tool:FindFirstChildWhichIsA("BasePart")
if not handle then
beam.Enabled = false
updateBoxColor(false)
return
end

beam.Enabled = true

att0.WorldPosition = handle.Position
att1.WorldPosition = targetPart.Position

local touching = false

for _,part in ipairs(handle:GetTouchingParts()) do
if part:IsDescendantOf(targetPart.Parent) then
touching = true
break
end
end

if touching then
beam.Color = ColorSequence.new(Color3.fromRGB(0,255,0))
else
beam.Color = ColorSequence.new(Color3.fromRGB(255,0,0))
end

updateBoxColor(touching)

end)

Features & Information

Sword helperrr etc

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts