What solutions have you tried so far? Did you look for solutions on the Developer Hub?
So far, I have tried to write scripts.
for i,Player in pairs(game.Players:GetPlayers()) do
for i,v in pairs(game.Workspace.Main_Room:GetChildren()) do
if v["Wood Chair"].Owned.Value == false then
Player.Character.Humanoid:MoveTo(v["Wood Chair"].Seat.Position)
v["Wood Chair"].Owned.Value = true
end
end
end
You’re looping through each player, and for each player, you loop through every chair. Meaning that only the first player will own a chair (they will teleport through all chairs, then all of the chair will be owned even though no one actually sits on it)
use break after setting the chair:
for i,Player in pairs(game.Players:GetPlayers()) do
for i,v in pairs(game.Workspace.Main_Room:GetChildren()) do
if v.Owned.Value == false then
Player.Character.Humanoid:MoveTo(v.Seat.Position)
v.Owned.Value = true
break;
end
end
end
Edit 3: I don’t know if your teleportation method works, but here’s another one just incase:
local Table = {}
for i,v in pairs(game.Workspace.Main_Room:GetChildren()) do
table.insert(Table, v)
end
for i,v in pairs(game.Players:GetPlayers()) do
repeat
local RandomChair = Table[math.random(1, #Table)] -- I have 18 chairs
v.Character:SetPrimaryPartCFrame(CFrame.new(RandomChair.Seat.Position))
table.remove(Table, Table[RandomChair])
until #Table == 0
end
local chairs = workspace.Main_Room:GetChildren()
for i, v in pairs(game.Players:GetPlayers()) do
if #chairs == 0 then break end -- ran out of chairs, stop the loop
local chairIndex = math.random(1, #chairs)
local seat = chairs[chairIndex].Seat
if v.Character then
local humanoid = v.Character:FindFirstChild("Humanoid")
if humanoid then
seat:Sit(humanoid)
table.remove(chairs, chairIndex) -- don't pick it again
end
end
end