Hi! My script isn’t working, it’s very messy because I have been focusing on getting it to work instead of making it fancy and clean.
I do ask that if you want to roast my script for being messy, you should clean it up yourself, as I am asking for help, not feedback. Thank you!
Server Side:
local CollectionService = game:GetService("CollectionService")
local PlayerInLobby = 0
local MaxPlayers = 1
local seed = 0
local function onTouched(hit: BasePart, part)
print(part.Name .. " touched by " .. hit.Name)
hit.Parent:AddTag("Lobby1")
hit.Parent:FindFirstChild("HumanoidRootPart").CFrame = script.Parent.Pad.CFrame
end
local function GetTextboxText(plr: Player, value: StringValue)
local textbox = plr.PlayerGui.ExtraUI.LobbyMaker.Seed.SeedTextBox
local text = value.Value
return string.byte(text)
end
-- Connect to all existing tagged parts
for _, part: BasePart in ipairs(CollectionService:GetTagged("1")) do
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not hit.Parent:HasTag("Lobby1") or hit.Parent:HasTag("Lobby2") or hit.Parent:HasTag("Lobby3") or hit.Parent:HasTag("Lobby4") then
print(GetTextboxText(game.Players:GetPlayerFromCharacter(hit.Parent), game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui:WaitForChild("ExtraUI").LobbyMaker.Seed.SeedTextBox.LocalScript:WaitForChild("Value")))
PlayerInLobby += 1
if PlayerInLobby == 1 then
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.ExtraUI.LobbyMaker.Visible = true
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.ExtraUI.LobbyMaker.Seperator3.SetSeed.MouseButton1Down:Connect(function()
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.ExtraUI.LobbyMaker.Visible = false
end)
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.ExtraUI.LobbyMaker.Seperator3.LeaveLobby.MouseButton1Down:Connect(function()
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.ExtraUI.LobbyMaker.Visible = false
hit.Parent:RemoveTag("Lobby1")
PlayerInLobby -= 1
game.Players:GetPlayerFromCharacter(hit.Parent).Character.HumanoidRootPart.CFrame = workspace.LobbySpawn.CFrame
end)
else
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.ExtraUI.ExitLobby.Visible = true
end
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.ExtraUI.ExitLobby.MouseButton1Down:Connect(function()
hit.Parent:RemoveTag("Lobby1")
PlayerInLobby -= 1
game.Players:GetPlayerFromCharacter(hit.Parent).Character.HumanoidRootPart.CFrame = workspace.LobbySpawn.CFrame
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.ExtraUI.ExitLobby.Visible = false
end)
if PlayerInLobby == 0 then
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.gui3.name.Text = "Lobby 1 – Ready to Join 🟩🟩🟩🟩🟩🟩"
elseif PlayerInLobby == 1 then
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.gui3.name.Text = "Lobby 1 – 1/"..MaxPlayers.." Players"
elseif PlayerInLobby == 2 then
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.gui3.name.Text = "Lobby 1 – 2/"..MaxPlayers.." Players"
elseif PlayerInLobby == 3 then
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.gui3.name.Text = "Lobby 1 – 3/"..MaxPlayers.." Players"
elseif PlayerInLobby == 4 then
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.gui3.name.Text = "Lobby 1 – 4/"..MaxPlayers.." Players"
elseif PlayerInLobby == 5 then
game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.gui3.name.Text = "Lobby 1 – 5/"..MaxPlayers.." Players"
end
onTouched(hit, part)
end
end
end)
end
Local Side:
script.Parent.Changed:Connect(function()
script:WaitForChild("Value").Value = script.Parent.Text
end)
Problem:
I have two problems:
One - If I enter it, then leave it, it stays at 1/1 players, but then if I enter again, then leave again, then enter again, it says ‘Ready to join’ as if it has 0 players, which it doesn’t.
Two - It always says the same seed. If I change it on studio, it changes the seed, but if I change it ingame it stays at whatever it was before.
Thank you for helping!