[Unsolved] I have problem with my create lobby

I have making game like project zomboid and got error
questions:

  1. What do you want to achieve? Keep it simple and clear!
    I have problem with my create lobby

  2. What is the issue? Include screenshots / videos if possible!
    I doing write code from this forum Making a Lobby system like Apeirophobia and if i click button start it sent it error
    Error output: Unable cast value to object

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I don’t know how to fix it, I stuck for this for 2 hours!

What server teleport and local script look like

TeleportServer

local plrs = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local teleportSS = game:GetService("TeleportService")

local Assets = rep:WaitForChild("Assets", 5)
local Events = Assets:WaitForChild("Events", 5)
local FunctionEvents = Assets:WaitForChild("FunctionEvents", 5)
local Modules = Assets:WaitForChild("Modules", 5)

local SafeTeleport = require(Modules.SafeTeleport)

--Events
local createEvent = Events:WaitForChild("CreateEvent", 5)
local joinEvent = Events:WaitForChild("JoinEvent", 5)
local startEvent = Events:WaitForChild("StartEvent", 5)
local updateGuiEvent = Events:WaitForChild("UpdateEvent", 5)
local lobbys = {}

local function SoloTeleport(plr)
	local placeId = 15994301748
	local options = Instance.new("TeleportOptions")
	SafeTeleport(placeId, {plr}, options)
	print("Finished Teleport")
end

local function Teleport(plrWaiting)
	local placeId = 15994301748
	local accessCode = teleportSS:ReserveServer(placeId)
	teleportSS:TeleportToPrivateServer(placeId, accessCode, plrWaiting)
	print("Finished Teleport")
end

Events:WaitForChild("SoloJoinEvent").OnServerEvent:Connect(SoloTeleport)

createEvent.OnServerEvent:Connect(function(plr)
	local userId = plr.UserId
	
	if not lobbys[userId] then
		lobbys[userId] = {
			players = {
				userId
			}
		}
		
		updateGuiEvent:FireAllClients(userId, "Add")
	end
end)

joinEvent.OnServerEvent:Connect(function(plr, userid)
	if not userid then return end
	
	userid = tonumber(userid)
	
	if lobbys[userid] and not table.find(lobbys[userid].players, plr.UserId) then
		table.insert(lobbys[userid].players, plr.UserId)
		updateGuiEvent:FireAllClients(userid, "Update", lobbys[userid].players)
	end
end)

startEvent.OnServerEvent:Connect(function(plr)
	local UserId = plr.UserId
	local lobby = lobbys[UserId]
	
	if not lobby then return end
	
	table.remove(lobbys, table.find(lobbys, lobby))
	
	Teleport(lobbys[UserId].players)
	
	updateGuiEvent:FireAllClients(UserId, "Remove")
end)

And local script in screen gui

local plrs = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local ts = game:GetService("TweenService")

local Assets = rep:WaitForChild("Assets", 5)
local Events = Assets:WaitForChild("Events", 5)
local FunctionEvents = Assets:WaitForChild("FunctionEvents", 5)
local Modules = Assets:WaitForChild("Modules", 5)

--Events
local createEvent = Events:WaitForChild("CreateEvent", 5)
local joinEvent = Events:WaitForChild("JoinEvent", 5)
local startEvent = Events:WaitForChild("StartEvent", 5)
local updateGuiEvent = Events:WaitForChild("UpdateEvent", 5)

local plr = plrs.LocalPlayer
local serverTemplate = script:WaitForChild("ServerTemplate", 5)

local frame = script.Parent
local ServerLists = frame:WaitForChild("ServerList", 5)

local cloned
updateGuiEvent.OnClientEvent:Connect(function(lobbyId, action, queue)
	if action == "Add" then
		local plrName = plrs:GetNameFromUserIdAsync(lobbyId)
		cloned = serverTemplate:Clone()
		cloned.Parent = ServerLists
		cloned.ServerOwner.Text = "Owner: " .. plrName
		cloned.ServerQueue.Text = "Queue: 1/4"
		cloned.Actions.ServerJoin.MouseButton1Click:Connect(function()
			joinEvent:FireServer(lobbyId)
		end)

		if lobbyId == plr.UserId then
			cloned.Actions.ServerStart.Visible = true
			cloned.Actions.ServerStart.MouseButton1Click:Connect(function()
				startEvent:FireServer()
			end)
		end
	elseif action == "Remove" then
		cloned:Destroy()
	elseif action == "Update" then
		cloned.ServerQueue.Text = "Queue: " .. #queue .. "/4"
	end
end)

Oh i forgot create lobby button local script here what is look like

local rep = game:GetService("ReplicatedStorage")
local ts = game:GetService("TweenService")

local Assets = rep:WaitForChild("Assets", 5)
local Events = Assets:WaitForChild("Events", 5)
local FunctionEvents = Assets:WaitForChild("FunctionEvents", 5)
local Modules = Assets:WaitForChild("Modules", 5)

--Events
local createEvent = Events:WaitForChild("CreateEvent", 5)

local ButtonsFrame = script.Parent
local SFX = ButtonsFrame.Parent:WaitForChild("Sounds", 5)

for i, label in pairs(ButtonsFrame:GetChildren()) do
	if label:IsA("TextLabel") then
		label.MouseEnter:Connect(function()
			ts:Create(label.Status, TweenInfo.new(0.5), {BackgroundTransparency = 0.85}):Play()
			SFX:WaitForChild("Select"):Play()	
		end)
		
		label.MouseLeave:Connect(function()
			ts:Create(label.Status, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
		end)
		
		label.Status.MouseButton1Click:Connect(function()
			SFX:WaitForChild("Click"):Play()
			
			if label.Text == "SOLO" then
				Events:WaitForChild("SoloJoinEvent"):FireServer()
			end
		end)
	end
end

local Popups = {
	JoinText = "Joins",
}

for btnName, frameName in pairs(Popups) do
	local btn = ButtonsFrame:FindFirstChild(btnName)
	local popupFrame = ButtonsFrame.Parent.Popups:FindFirstChild(frameName)
	
	btn.Status.MouseButton1Click:Connect(function()
		for i, v in pairs(ButtonsFrame:GetDescendants()) do
			if v:IsA("TextButton") then
				v.Visible = false
			end
		end
		
		for i, x in pairs(ButtonsFrame.Parent.Popups:GetChildren()) do
			if x:IsA("Frame") then
				x.Visible = false
			end
		end

		popupFrame.Visible = true
	end)
end

ButtonsFrame.HostText.Status.MouseButton1Click:Connect(function()
	createEvent:FireServer()
end)

Sorry about that for my english gramar

1 Like

I will wait here for replies this forum