Not sure what happening here but i have a gui that fire’s to server, it only randomly fires to server, its not clicking to early or anything, if i wait like 20 seconds and still click sometimes it wont fire
Theres no errors or anything, so im not sure whats going on but heres the code if it helps
-- Variables
local LobbyFrame = script.Parent
local CLobbyButton = LobbyFrame.CreateLobby
local ServerList = LobbyFrame.ServerScrollingFrame
local CreateLobbyFrame = LobbyFrame.CreateLobbyFrame
local BaseLobbyFrame = game.ReplicatedStorage.Stuff:WaitForChild("BaseServerFrame")
local CreateLobbyEvent = game.ReplicatedStorage.Events:WaitForChild("CreateLobby")
local LobbysFolder = game.ReplicatedStorage.Lobbys
local Lobbys = {}
-- Functions
local function UpdateLobby(Frame, Lobby)
while task.wait(.4) do
if not Frame or not Lobby then break end
local Success, ErrorMessage = pcall(function()
Frame.PlayerSlot.Text = #Lobby:FindFirstChild("Players"):GetChildren() .. "/" .. Lobby:FindFirstChild("MaxPlayers").Value
end)
if not Success then break end
end
end
local function LobbyAdded(Lobby)
if not Lobby.ClassName == "Folder" then return end
local Frame = BaseLobbyFrame:Clone()
Frame.Name = Lobby:WaitForChild("RoomName").Value
Frame.RoomName.Text = Lobby.RoomName.Value
Frame.Parent = ServerList
Frame.PlayerSlot.Text = #Lobby:FindFirstChild("Players"):GetChildren() .. "/" .. Lobby:FindFirstChild("MaxPlayers").Value
Lobbys[Lobby] = Frame
local UpdateCoroutine = coroutine.create(UpdateLobby)
coroutine.resume(UpdateCoroutine, Frame, Lobby)
end
local function LobbyRemoved(Lobby)
if not Lobby.ClassName == "Folder" then return end
if not Lobbys[Lobby] then return end
local Frame = Lobbys[Lobby]
Frame:Destroy()
end
-- Main
-- Event Functions
CLobbyButton.Activated:Connect(function()
-- RoomName, MaxPlayers, Map, IsLocked?, Password
CreateLobbyEvent:FireServer("Test: " .. math.random(1, tick()), math.random(2,10), "Map1", true, "ez")
end)
LobbysFolder.ChildAdded:Connect(LobbyAdded)
LobbysFolder.ChildRemoved:Connect(LobbyRemoved)
local function d_()
if CreateLobbyFrame.Visible == true then
CreateLobbyFrame.Visible = false
ServerList.Visible = true
else
ServerList.Visible = false
CreateLobbyFrame.Visible = true
end
end