So, I’ve made a server system. And im encountering a bug where player still can join them but the server table is full. Is there any fix i can do for this?
if Players.inServer.Value ~= true and v.JoinButton.Text == "JOIN" then
if tableData[v.JoinButton.Parent.Name].MaxPlayer > #tableData[v.JoinButton.Parent.Name].players then
print("Player can join this room")
if not joinDebounce then
joinDebounce = true
JoinEvent:FireServer(v.Name)
v.JoinButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
v.JoinButton.Text = "LEAVE"
print(Players.Name .. " Joined " .. v.Name)
Players.inServer.Value = true
task.wait(.5)
joinDebounce = false
end
end
end
yeah i did
Lets just say P1 and P2 is inside the room/table and then P3 Wanted to join that duo room
And when P3 Clicked the join button the button changed like the one in code but he is not in the room or table
This script is a bit irritating, but I think I may have found atleast one problem. Your if starts with if Players.inServer.Value ~= true and later you set Players.inServer.Value = true. That means that the whole if will be run 1 time and afterwards always be skipped because Players.inServer.Value is true. Another thing, which isn’t a problem but irritating, why do you set v.JoinButton.Text = "LEAVE", like, what’s this whole joinDebounce do? Did you also maybe misunderstand or even change Players? Because Players normally represents all players but in your case, considering you use Players.Name, it seems like you use it for a single player.
Players is local player.
I added debounce so joining is a bit delayed and prevent some error happening in
v.JoinButton.Leave is so that player can leave the room
Ah ok, very irritating indeed then. Then maybe you have forgotten to add the player to tableData[v.JoinButton.Parent.Name].players as there’s a check if tableData[v.JoinButton.Parent.Name].MaxPlayer > #tableData[v.JoinButton.Parent.Name].players but I can’t see the player being added to that table.
So if you never add players or only later, it won’t work. But did you actually mean JoinEvent:FireServer(v.Name)? Because this looks like a client-side script, but if you change variables server-side, even on ModuleScripts, those are not automatically synced.