Been working on this lobby system, and for some reason no matter how hard I try, the leave button appears for all clients I test with.
Basically, when I enter the trigger, it brings up the gui that i want it to bring up, but it enables the Gui for everybody, keep in mind that the remote events are client sided, and it still fires for everybody. If you have a solution to this let me know, because it’s getting annoying lol.
Serverside:
Players = game:GetService("Players")
LobbyJoiner = script.Parent
TeleportService = game:GetService("TeleportService")
TeleportOptions = Instance.new("TeleportOptions")
TeleportOptions.ShouldReserveServer = true
PlayerCount = 0
MaxPlayerCount = 9
PlayerCountGUI = script.Parent.SurfaceGui
LeaveGUI = game.StarterGui.LeaveGUI.Frame
PlayersInQueue = {}
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)--If you are editing because of the errors, don't worry the script works. The errors don't really mean much, since again it works well, i have tested with multple players, so don't worry.
local gui = player.PlayerGui
if hit.Parent:FindFirstChild("Humanoid") and PlayerCount ~= MaxPlayerCount then
for i, v in pairs(PlayersInQueue) do
if v == player then
return
end
end
game.ReplicatedStorage.guiOn:FireClient(player)
PlayerCount += 1
table.insert(PlayersInQueue, player)
print(PlayerCount)
print(PlayersInQueue)
script.Parent.SurfaceGui.Frame.TextLabel.Text = PlayerCount .. " / " .. MaxPlayerCount
end
gui.LeaveGUI.Frame.StoryModeExit1.MouseButton1Down:Connect(function()
for i, v in pairs(PlayersInQueue) do
if v == player then
table.remove(PlayersInQueue, i)
PlayerCount -= 1
game.ReplicatedStorage.guiOn:FireClient(player)
print(PlayerCount)
print(PlayersInQueue)
hit.Parent:WaitForChild("HumanoidRootPart").Position = workspace:FindFirstChild("Map").TeleportExits.Elevator1TpExit.Position
script.Parent.SurfaceGui.Frame.TextLabel.Text = PlayerCount .. " / " .. MaxPlayerCount
end
end
end)
end)
Client Side (Remote Event)
game.ReplicatedStorage.guiOn.OnClientEvent:Connect(function(player)
game.Players.LocalPlayer.PlayerGui.LeaveGUI.Enabled = true
end)
game.ReplicatedStorage.guiOff.OnClientEvent:Connect(function(player)
game.Players.LocalPlayer.PlayerGui.LeaveGUI.Enabled = false
end)
