#Matchmaking TextLabel doesnt change text. (Still Doesnt work need help)

1 messages · Page 1 of 1 (latest)

limpid flax
#

Hello! I am working on my own Matchmaking system. I want to see if it works, so for that I need to make the text Label show text and update it based on how many players are in the queue. I will show the scripts soon.

#
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local MemoryStoreService = game:GetService("MemoryStoreService")
local TeleportService = game:GetService("TeleportService")

local joinQueueEvent = ReplicatedStorage:WaitForChild("GLSolo")
local updateQueueLabelEvent = ReplicatedStorage:WaitForChild("UpdateQueueLabelSolo")

local queue = MemoryStoreService:GetQueue("GlobalMatchQueue")
local MAX_PLAYERS = 4
local MATCH_PLACE_ID = 132817753335599

-- When a player clicks to join the queue
joinQueueEvent.OnServerEvent:Connect(function(player)
    print(player.Name .. " is joining the global queue...")

    local success, err = pcall(function()
        queue:AddAsync(player.UserId, 60) -- player stays in queue for 60 seconds
    end)

    if not success then
        warn("Queue add failed:", err)
    end
end)

Script too long for me to send so Part 1

#
-- Matchmaker loop
task.spawn(function()
    while true do
        task.wait(5)

        print("Matchmaker checking queue...")
        local items = {}
        local peekSuccess, peekErr = pcall(function()
            items = queue:ReadAsync(MAX_PLAYERS, true)
        end)

        if peekSuccess then
            local currentCount = #items
            print("Queue has", currentCount, "players waiting.")

            -- Fire updated count to all players
            for _, plr in ipairs(Players:GetPlayers()) do
                updateQueueLabelEvent:FireClient(plr, currentCount, MAX_PLAYERS)
            end

            -- Start match if full
            if currentCount == MAX_PLAYERS then
                local userIds = {}
                local readSuccess, readErr = pcall(function()
                    userIds = queue:ReadAsync(MAX_PLAYERS, false)
                end)

                if readSuccess then
                    print("Match ready with:", table.concat(userIds, ", "))

                    local code
                    local reserveSuccess, reserveErr = pcall(function()
                        code = TeleportService:ReserveServer(MATCH_PLACE_ID)
                    end)

                    if reserveSuccess then
                        for _, userId in ipairs(userIds) do
                            local plr = Players:GetPlayerByUserId(userId)
                            if plr then
                                TeleportService:TeleportToPrivateServer(MATCH_PLACE_ID, code, {plr})
                            end
                        end
                    else
                        warn("Server reserve failed:", reserveErr)
                    end
                else
                    warn("Queue read failed:", readErr)
                end
            end
        else
            warn("Queue peek failed:", peekErr)
        end
    end
end)

Part 2. It's a server script.

#

And lastly the local script:

local plr = game.Players.LocalPlayer
local button = plr.PlayerGui.MatchakingGUI.TextButton
local label = plr.PlayerGui.MatchakingGUI.PlayerText

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local joinQueueEvent = ReplicatedStorage:WaitForChild("GLSolo")
local updateQueueLabelEvent = ReplicatedStorage:WaitForChild("UpdateQueueLabelSolo")

button.MouseButton1Click:Connect(function()
    print("Button clicked, requesting to join queue")
    joinQueueEvent:FireServer()
end)

updateQueueLabelEvent.OnClientEvent:Connect(function(plr, current, max)
    label.Text = current .. "/" .. max .. " Players"
end)
#

Obviously inside the replicated storage I have the remote event called: "UpdateQueueLabelSolo" that manages updating the text label.

#

The typo in the 2nd and 3rd line it the local script are okay, I made a typo in the name of the GUI so it's technically okay

sly shard
#

So what does the label text display ?

limpid flax
#

Well it displays what it displays by normal: 0/4 Players

#

And once I click the Join Queue button, it doesnt change to 1/4 players.

sly shard
#

If i am not mistaken, I think your problem may be in your OnClientEvent, since it should not pass trough the "plr" varible into it

so it should be like this instead

updateQueueLabelEvent.OnClientEvent:Connect(function(current, max)
    label.Text = current .. "/" .. max .. " Players"
end)```
limpid flax
#

Okay I'll try

#

I tried it, still doesn't work.. Did you find any other mistakes?

sly shard
#

let me take a look

oak sealBOT
#

studio** You are now Level 1! **studio

limpid flax
#

Alright

sly shard
#

A problem may be that your script dosent get the gui and label etc. Try changing it to waitforchild for extra securing

like this :

local gui = plr:WaitForChild("PlayerGui"):WaitForChild("MatchakingGUI")
local button = gui:WaitForChild("TextButton")
local label = gui:WaitForChild("PlayerText")
limpid flax
#

Okay

#

Damn, still doesn't work. I dont know what is the problem...

sly shard
#

hmmm try putting some prints into the functions and events to see if the script even recives them

limpid flax
#

So should I add more?

sly shard
#

add one into

updateQueueLabelEvent.OnClientEvent:Connect(function(current, max)
label.Text = current .. "/" .. max .. " Players"
end)

and see if the event prints it

#

then we'll know if it recives the call

limpid flax
#

Good idea, ill do that

#

Okay, now we know

#

it doesnt receive the call

sly shard
#

Well thats good to know, then we'll know where we have to look

limpid flax
#

yep

sly shard
#

where have you put your localscript?

limpid flax
#

Inside the matchmaking gui

#

surface gui

sly shard
#

So its inside the PlayerGui?

limpid flax
#

yes

sly shard
#

Sorry i meant the starerGui Folder

limpid flax
#

yes

sly shard
#

Is the screenGui its inside enabled?

limpid flax
#

Yes, it is

sly shard
#

hmmm

#

so your OnClientEvent looks like this :


updateQueueLabelEvent.OnClientEvent:Connect(function(current, max)
    label.Text = current .. "/" .. max .. " Players"
end)

and like this in server :


updateQueueLabelEvent:FireClient(plr, currentCount, MAX_PLAYERS)

oak sealBOT
#

studio** You are now Level 2! **studio

limpid flax
#

yes

sly shard
#

then i really don't see the problem with your code i'm sorry

limpid flax
#

It's okay, I'll try to find it