I got a problem for my game, i’m making a match system, similar to fall guys, or stumble guys. I came across of it working, but only for the player itsself, I’ve tried to fix it but it never synced correctly, can anyone help me?
Here is the script
function StartSolo(p1, p2)
local player1 = game:GetService("Players"):FindFirstChild(p1.Name)
if player1 then
local playerGui = player1:WaitForChild("PlayerGui"):WaitForChild("Main")
local findingMatch = playerGui:WaitForChild("FindingMatch")
local main = playerGui:WaitForChild("Main")
findingMatch.Visible = true
main.Visible = false
else
warn("Player not found.")
return
end
local Matchid = 16199854031
local TPS = game:GetService("TeleportService")
local PlayersInQueue = p2
local MinPlayers = 1
local MaxPlayers = 15
local IsMatchMaking = false
local function MatchMake()
if IsMatchMaking == false then
IsMatchMaking = true
repeat wait()
for i, v in pairs(PlayersInQueue) do
game.ReplicatedStorage.UpdateStatus:FireClient(v, "Waiting for at least " .. tostring(MinPlayers))
end
until #PlayersInQueue >= MinPlayers
print("Starting Match!")
for i = 0, 15, 1 do
if #PlayersInQueue == 0 then
IsMatchMaking = false
-- Player has left the game or quit looking
return
end
if #PlayersInQueue == MaxPlayers then
break
end
for _, value in pairs(PlayersInQueue) do
game.ReplicatedStorage.UpdateStatus:FireClient(value, "Teleporting to Match in: (" .. tostring(15 - i) .. ") Seconds! Players in Queue: (" .. tostring(#PlayersInQueue) .. ")")
end
wait(1)
end
local success, errorMessage = pcall(function()
local Server = TPS:ReserveServer(Matchid)
TPS:TeleportToPrivateServer(Matchid, Server, PlayersInQueue)
end)
if not success then
print("telport Failed..")
if player1 then
local playerGui = player1:WaitForChild("PlayerGui"):WaitForChild("Main")
local DeclineMessage = playerGui.Message:Clone()
DeclineMessage.Title.Text = "Match Teleport"
DeclineMessage.Main.Text = "Your Teleport to your Match Failed, Try again! 😔"
DeclineMessage.Ok.Visible = true
DeclineMessage.Visible = true
DeclineMessage.Parent = playerGui
DeclineMessage.ExitButton.MouseButton1Click:Connect(function()
DeclineMessage:Destroy()
end)
DeclineMessage.Ok.ExitButton.MouseButton1Click:Connect(function()
DeclineMessage:Destroy()
end)
else
warn("Player not found.")
return
end
end
wait(4)
PlayersInQueue = {}
IsMatchMaking = false
end
end
if not table.find(PlayersInQueue, player1) then
table.insert(PlayersInQueue, player1)
end
MatchMake()
game.Players.PlayerRemoving:Connect(function(player)
for i, v in pairs(PlayersInQueue) do
if v == player1 then
table.remove(PlayersInQueue, i)
end
end
end)
end
local remoteFunction2 = game:GetService("ReplicatedStorage").StartShow
remoteFunction2.OnServerInvoke = function(player)
local PartyTable = {}
local PartysFolder = game:GetService("ReplicatedStorage").Partys
if PartysFolder:FindFirstChild(player.Name) then
local PlayerNew = PartysFolder:FindFirstChild(player.Name)
local OwnerOfParty = PlayerNew.Value
if OwnerOfParty then
for _, v in pairs(PartysFolder:GetChildren()) do
if v.Name == OwnerOfParty and v.Name ~= player.Name then
local OtherPlayer = v.Name
table.insert(PartyTable, player.Name)
table.insert(PartyTable, OtherPlayer)
print(PartyTable)
StartShow(player, v, false) -- if no other players than just put false ig
end
end
end
else
print("Going Solo!")
StartSolo(player, PlayersInQueue)
end
end
What exactly are you trying to do? Please explain by “syncing”.
Im trying to make it so it displays the players and how many are in that table, i want it to sync with the timer, for example if a player joins first and the other player joins it glitches the timer for both since its interfering with it from the other player,