You can write your topic however you want, but you need to answer these questions:
1.I want to figure it out how to make it so if one of the players that are paired together press the leave button they get unpaired no matter which one of them pressed it
- My problem is that if the player who gets asked to pair leaves the pair it works as intended however if the player who asked to pair tries to leave the event is being trigger 2 times and it only removes the pair from their side but the other player is still paired to them
3.I tried pretty much everything but I cant figure out the issue
The server side script is this:
local ReplicatedStorage = game.ReplicatedStorage
local Event1 = ReplicatedStorage.Pairing
local Event2 = ReplicatedStorage.UnPaired
local players = game.Players
local PairingMenu = ReplicatedStorage.PairingMenu:Clone()
local Paired = false
local Player2 = nil
local PlayerPairs = {}
Event2.OnServerEvent:Connect(function(Player1)
Paired = false
Event2:FireClient(Player1)
Event2:FireClient(Player2)
PlayerPairs[Player1] = nil
PlayerPairs[Player2] = nil
print(Player2)
end)
local PairedAccepted = ReplicatedStorage[“Paired Accepted”]:Clone()
local function Triggered(player1,player2)
print(PlayerPairs)
local PairingMenu2 = PairingMenu:Clone()
local Frame = PairingMenu2.Frame
local Text = Frame.TextLabel
local Yes = Frame.Yes
local No = Frame.No
PairingMenu2.Parent = player1.PlayerGui
Text.Text = “”…player2.Name…“Sent you a pair”…“”
Yes.MouseButton1Click:Connect(function()
PlayerPairs[player1] = player2
PlayerPairs[player2] = player1
print(PlayerPairs)
Paired = true
Event1:FireClient(player1,player2)
Event1:FireClient(player2,player1)
Player2 = player2
PairingMenu2:Destroy()
local Paired = PairedAccepted:Clone()
Paired.Parent = player1.PlayerGui
local Paired2 = Paired:Clone()
Paired2.Parent = player2.PlayerGui
wait(0.5)
Paired2:Destroy()
Paired:Destroy()
end)
No.MouseButton1Click:Connect(function()
PairingMenu2:Destroy()
end)
end
local function OnCharacterAdded(Character,player1)
local Prompt = Instance.new(“ProximityPrompt”)
Prompt.Parent = Character
Prompt.Triggered:Connect(function(player2)
if not PlayerPairs[player1] and not PlayerPairs[player2] then
Triggered(player1,player2)
end
end)
end
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
OnCharacterAdded(character,player)
end)
end)
and the Client Side script is this:
local ReplicatedStorage = game.ReplicatedStorage
local RemoteEvent1 = ReplicatedStorage.Pairing
local RemoteEvent2 = ReplicatedStorage.UnPaired
local Teammate = nil
local Player = game.Players.LocalPlayer
local Gui = Player.PlayerGui:WaitForChild(“UnPair”)
local Text = Gui.TextButton
local Paired = false
local Stuff = {}
local function AddStuff()
if Paired then
print(“AddingStuff”)
local Beam = Instance.new(“Beam”)
Beam.Attachment0 = Player.Character.HumanoidRootPart.RootAttachment
Beam.Attachment1 = Teammate.Character.HumanoidRootPart.RootAttachment
Beam.Parent = workspace
Beam.Name = “Beam of”…Player.Name…Teammate.Name…“”
table.insert(Stuff,Beam)
else
print(“RemovingStuff”)
for i,v in pairs(Stuff) do
v:Destroy()
end
end
end
local function QuitPair()
Paired = false
Teammate = nil
AddStuff()
end
local function AddTeammate(player2)
if not Paired then
Teammate = player2
Paired = true
AddStuff()
print(“Teammate “…Teammate.name…””)
end
end
RemoteEvent1.OnClientEvent:Connect(AddTeammate)
Text.MouseButton1Click:Connect(function()
RemoteEvent2:FireServer()
end)
RemoteEvent2.OnClientEvent:Connect(QuitPair)
Could someone please tell if something is wrong or guide me towards an better system