This is a simple matchmaking local script:
local OnTeleportation = false
local function UpdateButton()
print(OnTeleportation)
end
PlayButton.MouseButton1Click:Connect(function()
if not debounce then
debounce = true
if not OnMatchmaking then
OnMatchmaking = true
UpdateButton()
task.wait(3)
Matchmaking:FireServer(OnMatchmaking)
repeat task.wait() until QueuePlayers == 2 or OnMatchmaking == false
if QueuePlayers == 2 then
OnTeleportation = true
UpdateButton()
Matchmaking:FireServer(OnMatchmaking, "Teleportation")
end
else
OnMatchmaking = false
Matchmaking:FireServer(OnMatchmaking)
MessageHandler.IssueMessage("Matchmaking canceled.", 2)
task.spawn(function()
for i = 3, 0, -1 do
PlayButton.Text = i.."s"
task.wait(1)
end
PlayButton.Text = "Play"
debounce = false
end)
end
end
end)
The following issue happens:
There is a Player1 that clicks on the button, he joins the queue first and everything goes on correctly. But if there is a Player2 and there is someone on the queue already, when the UpdateButton function is called, it will simply return that OnTeleportation is false, when it should be true.
Please help me fix this issue!