just an update sorry to those replying, i got it!!
this is the solution for those who’re trying to achieve something similar:
local M6D:Motor6D = nil
local randomSeat:Seat = nil
local randomPlate = nil
local randomNo = nil
local numberTable = {}
function startGameModule.CreateM6D()
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAppearanceLoaded:Connect(function(c)
if c:FindFirstChild("plateM6D") then return end
M6D = Instance.new("Motor6D", c)
M6D.Name = "plateM6D"
end)
end)
end
function startGameModule.startGameFunction()
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local seatOFFSET=CFrame.new(0,2,0)
local seatFolder = workspace.tableModel.seatFolder
local plateFolder = workspace.tableModel.plateFolder
local hum:Humanoid = c.Humanoid
randomNo = Random.new():NextInteger(1,20)
print(randomNo.." is the seat number!")
if table.find(numberTable, randomNo) == true then
repeat
randomNo = Random.new():NextInteger(1,20)
wait(.1)
until table.find(numberTable, randomNo) == nil
end
table.insert(numberTable, randomNo)
wait()
randomSeat = seatFolder[`Seat{tostring(randomNo)}`]
randomPlate = plateFolder[`Plate{tostring(randomNo)}`]
if randomSeat:GetAttribute("occupied") == false then
c:PivotTo(randomSeat.CFrame * seatOFFSET)
wait()
randomSeat:Sit(hum)
if randomSeat.Occupant then
randomSeat:SetAttribute("occupied", true)
c:SetAttribute("sitAttribute", true)
randomSeat:SetAttribute("playerName", randomSeat.Occupant.Parent.Name)
randomPlate:SetAttribute("playerName", randomSeat.Occupant.Parent.Name)
randomPlate:SetAttribute("occupied", true)
randomPlate.Parent = c
M6D.Part1 = randomPlate
print({
p.Name.. randomSeat.Name,
p.Name.. randomPlate.Name
})
end
end
end)
end)
end
randomNo = Random.new():NextInteger(1,20)
print(randomNo.." is the seat number!")
if the seat number is in the table then roll the dice again basically until it finds a number not in the table:
if table.find(numberTable, randomNo) == true then
repeat
randomNo = Random.new():NextInteger(1,20)
wait(.1)
until table.find(numberTable, randomNo) == nil
end
insert the new number that isnt in the table
table.insert(numberTable, randomNo)
and remove the seat number from the table when someone leaves so the next person who joins can sit there: