0% found this document useful (0 votes)
14 views3 pages

LocalScript GUI for Player Interaction

This document is a Lua script for a Roblox game that creates a user interface allowing players to attach and throw other players. It includes functionalities for listing players, selecting a player, and managing attachments using AlignPosition and AlignOrientation. Additionally, it allows detaching players using a key press and handles player addition and removal dynamically.

Uploaded by

stewartpruden5
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
0% found this document useful (0 votes)
14 views3 pages

LocalScript GUI for Player Interaction

This document is a Lua script for a Roblox game that creates a user interface allowing players to attach and throw other players. It includes functionalities for listing players, selecting a player, and managing attachments using AlignPosition and AlignOrientation. Additionally, it allows detaching players using a key press and handles player addition and removal dynamically.

Uploaded by

stewartpruden5
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

-- LocalScript inside ScreenGui

local player = [Link]


local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")

local gui = [Link]


local frame = gui:WaitForChild("MainFrame")
local playerList = frame:WaitForChild("PlayerList")
local attachBtn = frame:WaitForChild("AttachButton")
local throwBtn = frame:WaitForChild("ThrowButton")

-- Make frame draggable


[Link] = true
[Link] = true

-- UI setup
[Link] = [Link](0, 200, 0, 250)
[Link] = [Link](0.05, 0, 0.3, 0)
frame.BackgroundColor3 = [Link](25,25,25)
[Link] = 0

[Link] = "Attach"
[Link] = [Link](1, -10, 0, 30)
[Link] = [Link](0,5,1,-70)

[Link] = "Throw"
[Link] = [Link](1, -10, 0, 30)
[Link] = [Link](0,5,1,-35)

[Link] = [Link](1, -10, 1, -120)


[Link] = [Link](0,5,0,30)
[Link] = [Link](0,0,0,0)
[Link] = 8
playerList.BackgroundColor3 = [Link](40,40,40)
[Link] = 0

-- Selected player
local selectedPlayer
local function updatePlayerList()
playerList:ClearAllChildren()
for _, plr in ipairs(Players:GetPlayers()) do
if plr ~= player then
local btn = [Link]("TextButton")
[Link] = [Link](1, -5, 0, 25)
[Link] = [Link]
btn.BackgroundColor3 = [Link](60,60,60)
btn.TextColor3 = [Link](1,1,1)
[Link] = playerList

btn.MouseButton1Click:Connect(function()
selectedPlayer = plr
for _,b in ipairs(playerList:GetChildren()) do
if b:IsA("TextButton") then
b.BackgroundColor3 = [Link](60,60,60)
end
end
btn.BackgroundColor3 = [Link](100,100,150)
end)
end
end
end

[Link]:Connect(updatePlayerList)
[Link]:Connect(updatePlayerList)
updatePlayerList()

-- Attach + Throw
local alignPos, alignOri, a0, a1

local function cleanAttachments()


if alignPos then alignPos:Destroy() end
if alignOri then alignOri:Destroy() end
if a0 then a0:Destroy() end
if a1 then a1:Destroy() end
alignPos, alignOri, a0, a1 = nil, nil, nil, nil
end

attachBtn.MouseButton1Click:Connect(function()
if not selectedPlayer or not [Link] then
warn("Select a player first")
return
end
cleanAttachments()

local myChar = [Link] or [Link]:Wait()


local targetChar = [Link]
local myRoot = myChar:WaitForChild("HumanoidRootPart")
local targetRoot = targetChar:WaitForChild("HumanoidRootPart")

a0 = [Link]("Attachment", targetRoot)
a1 = [Link]("Attachment", myRoot)
[Link] = [Link](0, 3, 0)

alignPos = [Link]("AlignPosition", targetRoot)


alignPos.Attachment0 = a0
alignPos.Attachment1 = a1
[Link] = 25000
[Link] = 50

alignOri = [Link]("AlignOrientation", targetRoot)


alignOri.Attachment0 = a0
alignOri.Attachment1 = a1
[Link] = 50

print("Attached "..[Link].." locally")


end)

throwBtn.MouseButton1Click:Connect(function()
if not a0 or not a1 then
warn("Nothing attached")
return
end
local targetRoot = [Link]
cleanAttachments()

local force = [Link]("BodyVelocity")


[Link] = [Link](1e5, 1e5, 1e5)
[Link] = ([Link] +
[Link](0,1,0)) * 120
[Link] = targetRoot

game:GetService("Debris"):AddItem(force, 1)
print("Threw "..[Link].." (local only)")
end)

-- Optional: Q key to detach


[Link]:Connect(function(input, gp)
if gp then return end
if [Link] == [Link].Q then
cleanAttachments()
print("Detached")
end
end)

You might also like