so i’ve been making a matchmaking system, and i’ve ran into some serious bugs.
- it cannot detect when someone wins
- the accept / decline match gui appears for the person who sent the match request
code:
SERVER
for i = time_in_round,0,-1 do
print(time_in_round)
print(winner)
time_in_round = time_in_round - 1
print("looping!")
time_ui.Visible = true
time_ui2.Visible = true
if i == 0 then
time_num.Text = "NO ONE WINS"
character1.Humanoid.WalkSpeed = 0
character2.Humanoid.WalkSpeed = 0
wait(4)
place:Destroy()
character1.Humanoid.Health = 0
character2.Humanoid.Health = 0
break
end
if player1:FindFirstChild("leaderstats").deaths.Value >= 4 then
winner = true
winners_name = player2.Name
end
if player2:FindFirstChild("leaderstats").deaths.Value >= 4 then
winner = true
winners_name = player1.Name
end
if winner == true then
print("we have a winner!")
print("the winner is "..winners_name)
time_num.Text = winners_name.." WON THE ROUND"
time_num2.Text = winners_name.." WON THE ROUND"
character1.Humanoid.WalkSpeed = 0
character2.Humanoid.WalkSpeed = 0
wait(4)
place:Destroy()
character1.Humanoid.Health = 0
character2.Humanoid.Health = 0
break
end
time_num.Text = i
time_num2.Text = i
wait(1)
end
remotes.match_make.OnServerEvent:Connect(function(challenged_plr,original_plr)
local accept_decline = challenged_plr:WaitForChild("PlayerGui").match_maker.accept_decline
accept_decline.Visible = true
remotes.match_make:FireClient(challenged_plr,accept_decline)
end)
CLIENT
local function players_check(text)
print(text)
print("got request")
for i,v in pairs(players:GetChildren())do
if v.Name == text then
local challenged_plr = v
print(v.Name.." got a challenge!")
remotes.match_make:FireServer(challenged_plr,plr)
remotes.match_make.OnClientEvent:Connect(function(accept_decline)
print(challenged_plr)
print(challenged_plr.Name)
for i,v in pairs(challenged_plr:GetChildren()) do
print(v)
end
--local accept_decline = challenged_plr:WaitForChild("PlayerGui").match_maker.accept_decline
local value = accept_decline.accepted
--accept_decline.Visible = true
accept_decline.text.Text = challenged_plr.Name.."HAS CHALLENGED YOU"
value:GetPropertyChangedSignal("Value"):Connect(function()
if value.Value == true then
remotes.round_creator:FireServer(challenged_plr,plr)
end
end)
end)
end
end
end