50% found this document useful (2 votes)
2K views

Drag Player FE (Dead Rails) !!! Very OP

The document contains a Lua script for a Roblox game that creates a draggable GUI with a button. When the button is clicked, it identifies the nearest player's character and sends a request to the server using a remote event. The script ensures the GUI is part of the player's screen and remains active even after respawning.

Uploaded by

aintzenith06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
2K views

Drag Player FE (Dead Rails) !!! Very OP

The document contains a Lua script for a Roblox game that creates a draggable GUI with a button. When the button is clicked, it identifies the nearest player's character and sends a request to the server using a remote event. The script ensures the GUI is part of the player's screen and remains active even after respawning.

Uploaded by

aintzenith06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

local player = game.Players.

LocalPlayer
local screenGui = Instance.new("ScreenGui")
local frame = Instance.new("Frame")
local button = Instance.new("TextButton")

screenGui.Parent = player:FindFirstChildOfClass("PlayerGui")
screenGui.ResetOnSpawn = false

frame.Size = UDim2.new(0, 200, 0, 100)


frame.Position = UDim2.new(0.5, -100, 0.5, -50)
frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
frame.Active = true
frame.Draggable = true
frame.Parent = screenGui

button.Size = UDim2.new(0, 150, 0, 50)


button.Position = UDim2.new(0.5, -75, 0.5, -25)
button.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
button.Text = "DRAG"
button.Parent = frame

local replicatedStorage = game:GetService("ReplicatedStorage")


local remote =
replicatedStorage:WaitForChild("Shared"):WaitForChild("Remotes"):WaitForChild("Requ
estStartDrag")

local function getNearestCharacter()


local nearestCharacter = nil
local shortestDistance = math.huge

if player.Character and player.Character:FindFirstChild("HumanoidRootPart")


then
local playerPosition = player.Character.HumanoidRootPart.Position

for _, otherPlayer in ipairs(game.Players:GetPlayers()) do


if otherPlayer ~= player and otherPlayer.Character and
otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
local targetHRP = otherPlayer.Character.HumanoidRootPart
local distance = (targetHRP.Position - playerPosition).Magnitude

if distance < shortestDistance then


shortestDistance = distance
nearestCharacter = otherPlayer.Character
end
end
end
end

return nearestCharacter
end

button.MouseButton1Click:Connect(function()
local nearestCharacter = getNearestCharacter()
if nearestCharacter then
remote:FireServer(nearestCharacter)
end
end)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy