I’m making a matchmaking system, and i’ve ran into a lot of problems.
I managed to solve 90% of them.
But, theres one issue.
Players are not receiving invites.
Client and server are mainly communicating between remote functions.
Servercode:
local parties = {
}
local function inv(who,inviting)
game.ReplicatedStorage.matchmaking.sendinvite:InvokeClient(inviting,who)
end
game.ReplicatedStorage.matchmaking.invite.OnServerInvoke = inv
local function sendinv(who,bool,sender)
if parties[sender.Name] then
if bool == true then
table.insert(parties[sender],who.Name)
game.ReplicatedStorage.matchmaking.invite:InvokeClient(bool)
else
game.ReplicatedStorage.matchmaking.invite:InvokeClient(bool)
end
else
parties[sender.Name] = {}
if parties[sender.Name] then
if bool == true then
table.insert(parties[sender],who.Name)
game.ReplicatedStorage.matchmaking.invite:InvokeClient(bool)
else
game.ReplicatedStorage.matchmaking.invite:InvokeClient(bool)
end
end
end
end
game.ReplicatedStorage.matchmaking.sendinvite.OnServerInvoke = sendinv
localscript MainCode for inviting players:
local List = script.Parent.Results
local partylist = script.Parent.Partylist
local close = script.Parent.Close
local Team = {}
local connectxion
function Opened()
connectxion = game.ReplicatedStorage[".playerchanged"].OnClientEvent:connect(function()
local ex = script.Parent.ex.user:Clone()
ex.Parent = List
for _,_p in pairs(game.Players:GetChildren()) do
if _p.Name == game.Players.LocalPlayer.Name then
-- nothing
else
if not _p:FindFirstChild('leaderstats') then
repeat
wait()
until _p:FindFirstChild('leaderstats')
if not List:FindFirstChild(_p.Name) then
ex.Name = _p.Name
ex.rate.Text = 'Rating:'.._p['leaderstats']['SuccessRate'].Value
ex.Text = _p.Name
ex.Visible = true
ex.inv.MouseButton1Click:Connect(function()
if game.Players:FindFirstChild(ex.Name) then
local inr = game.ReplicatedStorage.matchmaking.invite
inr:InvokeServer(game.Players[ex.Name])
local function b(bool)
if bool == true then
table.insert(Team,ex.Name)
local vx = script.Parent.plx.user:Clone()
vx.Parent = script.Parent.Partylist
vx.Name = ex.Name
vx.Text = ex.Name
vx.Visible = true
vx.rate.Text = ex.rate.Text
vx.rem.MouseButton1Click:Connect(function()
table.remove(Team,ex.Name)
end)
elseif bool == false then
ex.inv.Text = 'Rejected.'
wait(3)
ex.inv.Text = 'Invite'
end
end
inr.OnClientInvoke = b
else
ex:Destroy()
end
end)
end
else
if not List:FindFirstChild(_p.Name) then
ex.Name = _p.Name
ex.rate.Text = 'Rating:'.._p['leaderstats']['SuccessRate'].Value
ex.Text = _p.Name
ex.Visible = true
ex.inv.MouseButton1Click:Connect(function()
if game.Players:FindFirstChild(ex.Name) then
local inr = game.ReplicatedStorage.matchmaking.invite
inr:InvokeServer(game.Players[ex.Name])
local function b(bool)
if bool == true then
table.insert(Team,ex.Name)
local vx = script.Parent.plx.user:Clone()
vx.Parent = script.Parent.Partylist
vx.Name = ex.Name
vx.Text = ex.Name
vx.Visible = true
vx.rate.Text = ex.rate.Text
vx.rem.MouseButton1Click:Connect(function()
table.remove(Team,ex.Name)
end)
elseif bool == false then
ex.inv.Text = 'Rejected.'
wait(3)
ex.inv.Text = 'Invite'
end
end
inr.OnClientInvoke = b
else
ex:Destroy()
end
end)
end
end
end
end
end)
end
function Closed()
for _,_res in pairs(List:GetChildren()) do
if _res.Name == 'UIListLayout' then
-- nothing
else
_res:Destroy()
end
end
for _,_res in pairs(partylist:GetChildren()) do
if _res.Name == 'UIListLayout' then
-- nothing
else
_res:Destroy()
Team = {}
end
end
connectxion:Disconnect()
connectxion = ''
partylist.Visible = false
List.Visible = false
close.Visible = false
end
Opened()
close.MouseButton1Click:Connect(function()
Closed()
end)
localscript Showing Invites to players:
local function z(inviting,sender)
if inviting.Name == game.Players.LocalPlayer.Name then
local accepted = script.Parent.bg.a
local declined = script.Parent.bg.d
local label = script.Parent.bg.has
label.Text = sender.Name..[[ has invited you to their party.]]
script.Parent.bg.Visible = true
accepted.MouseButton1Click:Connect(function()
script.Parent.bg.Visible = false
game.ReplicatedStorage.matchmaking.sendinvite:InvokeServer(true,sender)
end)
declined.MouseButton1Click:Connect(function()
script.Parent.bg.Visible = false
game.ReplicatedStorage.matchmaking.sendinvite:InvokeServer(false,sender)
end)
else
-- nothing
end
end
game.ReplicatedStorage.matchmaking.sendinvite.OnClientInvoke = z
I am looking for suggestions, solutions.