local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
-- Wait for RemoteEvents
local ropeEvents = ReplicatedStorage:WaitForChild("RopeEvents")
local requestPair = ropeEvents:WaitForChild("RequestPair")
local respondPair = ropeEvents:WaitForChild("RespondPair")
local pullPartner = ropeEvents:WaitForChild("PullPartner")
local unpair = ropeEvents:WaitForChild("Unpair")
local currentPartner = nil
local isPaired = false
-- Create GUI
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "RopeSystemGUI"
screenGui.Parent = playerGui
-- Pairing button
local pairButton = Instance.new("TextButton")
pairButton.Name = "PairButton"
pairButton.Size = UDim2.new(0.15, 0, 0.05, 0)
pairButton.Position = UDim2.new(0.85, 0, 0.1, 0)
pairButton.BackgroundColor3 = Color3.new(0.2, 0.6, 0.2)
pairButton.TextColor3 = Color3.new(1, 1, 1)
pairButton.Text = "Request Pair"
pairButton.TextScaled = true
pairButton.Parent = screenGui
-- Player list frame
local playerListFrame = Instance.new("Frame")
playerListFrame.Name = "PlayerList"
playerListFrame.Size = UDim2.new(0.2, 0, 0.3, 0)
playerListFrame.Position = UDim2.new(0.8, 0, 0.2, 0)
playerListFrame.BackgroundColor3 = Color3.new(0.1, 0.1, 0.1)
playerListFrame.BackgroundTransparency = 0.3
playerListFrame.Visible = false
playerListFrame.Parent = screenGui
-- Notification frame
local notificationFrame = Instance.new("Frame")
notificationFrame.Name = "Notification"
notificationFrame.Size = UDim2.new(0.3, 0, 0.15, 0)
notificationFrame.Position = UDim2.new(0.35, 0, 0.4, 0)
notificationFrame.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)
notificationFrame.Visible = false
notificationFrame.Parent = screenGui
local notificationText = Instance.new("TextLabel")
notificationText.Size = UDim2.new(1, 0, 0.6, 0)
notificationText.BackgroundTransparency = 1
notificationText.TextColor3 = Color3.new(1, 1, 1)
notificationText.TextScaled = true
notificationText.Parent = notificationFrame
local acceptButton = Instance.new("TextButton")
acceptButton.Size = UDim2.new(0.4, 0, 0.3, 0)
acceptButton.Position = UDim2.new(0.05, 0, 0.65, 0)
acceptButton.BackgroundColor3 = Color3.new(0.2, 0.8, 0.2)
acceptButton.Text = "Accept"
acceptButton.TextScaled = true
acceptButton.Parent = notificationFrame
local declineButton = Instance.new("TextButton")
declineButton.Size = UDim2.new(0.4, 0, 0.3, 0)
declineButton.Position = UDim2.new(0.55, 0, 0.65, 0)
declineButton.BackgroundColor3 = Color3.new(0.8, 0.2, 0.2)
declineButton.Text = "Decline"
declineButton.TextScaled = true
declineButton.Parent = notificationFrame
-- Status label
local statusLabel = Instance.new("TextLabel")
statusLabel.Size = UDim2.new(0.3, 0, 0.05, 0)
statusLabel.Position = UDim2.new(0.35, 0, 0.05, 0)
statusLabel.BackgroundTransparency = 1
statusLabel.TextColor3 = Color3.new(1, 1, 1)
statusLabel.TextScaled = true
statusLabel.Text = ""
statusLabel.Parent = screenGui
-- Function to update player list
local function updatePlayerList()
-- Clear existing buttons
for _, child in ipairs(playerListFrame:GetChildren()) do
if child:IsA("TextButton") then
child:Destroy()
end
end
-- Add player buttons
local yOffset = 0
for _, otherPlayer in ipairs(Players:GetPlayers()) do
if otherPlayer ~= player then
local playerButton = Instance.new("TextButton")
playerButton.Size = UDim2.new(0.9, 0, 0.2, 0)
playerButton.Position = UDim2.new(0.05, 0, yOffset, 0)
playerButton.Text = otherPlayer.Name
playerButton.TextScaled = true
playerButton.Parent = playerListFrame
playerButton.MouseButton1Click:Connect(function()
requestPair:FireServer(otherPlayer)
playerListFrame.Visible = false
end)
yOffset = yOffset + 0.25
end
end
end
-- Toggle player list when clicking pair button
pairButton.MouseButton1Click:Connect(function()
if isPaired then
unpair:FireServer()
else
playerListFrame.Visible = not playerListFrame.Visible
if playerListFrame.Visible then
updatePlayerList()
end
end
end)
-- Handle incoming pair requests
requestPair.OnClientEvent:Connect(function(requester)
notificationText.Text = requester.Name .. " wants to pair with you!"
notificationFrame.Visible = true
local connection1, connection2
connection1 = acceptButton.MouseButton1Click:Connect(function()
respondPair:FireServer(requester, true)
notificationFrame.Visible = false
connection1:Disconnect()
connection2:Disconnect()
end)
connection2 = declineButton.MouseButton1Click:Connect(function()
respondPair:FireServer(requester, false)
notificationFrame.Visible = false
connection1:Disconnect()
connection2:Disconnect()
end)
end)
-- Handle pairing response
respondPair.OnClientEvent:Connect(function(partner, accepted)
if accepted then
currentPartner = partner
isPaired = true
statusLabel.Text = "Paired with " .. partner.Name
pairButton.Text = "Unpair"
pairButton.BackgroundColor3 = Color3.new(0.8, 0.2, 0.2)
else
statusLabel.Text = partner.Name .. " declined your request"
wait(3)
statusLabel.Text = ""
end
end)
-- Handle unpairing
unpair.OnClientEvent:Connect(function()
currentPartner = nil
isPaired = false
statusLabel.Text = ""
pairButton.Text = "Request Pair"
pairButton.BackgroundColor3 = Color3.new(0.2, 0.6, 0.2)
end)
-- Handle pulling partner with E key
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.E and isPaired then
pullPartner:FireServer()
end
end)
-- Add instructions
local instructionLabel = Instance.new("TextLabel")
instructionLabel.Size = UDim2.new(0.3, 0, 0.1, 0)
instructionLabel.Position = UDim2.new(0.35, 0, 0.9, 0)
instructionLabel.BackgroundTransparency = 1
instructionLabel.TextColor3 = Color3.new(1, 1, 1)
instructionLabel.TextScaled = true
instructionLabel.Text = "Press E to pull your partner when they fall"
instructionLabel.Parent = screenGui