hello! i have a table with chairs and plates 1-20. when the player joins, a player will be sat in a seat and their name will be stored in the seat’s and plate’s attributes. storing the name in the seat works but not for the plate. i tried something but it didnt work. ty!
eg:
if a player joins and gets seat 1, their name will be stored in seat 1 and in plate 1.
script:
function startGameModule.startGameFunction()
game.Players.PlayerAdded:Connect(function(p)
wait(3)
local c = p.Character
local seatOFFSET=CFrame.new(0,2,0)
local seatFolder = workspace.tableModel.seatFolder
local plateFolder = workspace.tableModel.plateFolder
local hum:Humanoid = c.Humanoid
randomSeat = seatFolder:GetChildren()[math.random(1, #seatFolder:GetChildren())]
randomPlate = plateFolder:GetChildren()[math.random(1, #plateFolder:GetChildren())]
if randomSeat:GetAttribute("occupied") == false then
c:PivotTo(randomSeat.CFrame* seatOFFSET)
wait()
randomSeat:Sit(hum)
if randomSeat.Occupant then
randomSeat:SetAttribute("occupied", true)
randomSeat:SetAttribute("playerName", randomSeat.Occupant.Parent.Name)
randomPlate:SetAttribute("playerName", randomSeat.Occupant.Parent.Name)
print(randomSeat.Name)
print(randomPlate.Name)
end
end
end)
end
local randomSeat:Seat = nil
local randomPlate = nil
local randomNo = Random.new():NextInteger(1, 20)
function startGameModule.startGameFunction()
game.Players.PlayerAdded:Connect(function(p)
wait(3)
local c = p.Character
local seatOFFSET=CFrame.new(0,2,0)
local seatFolder = workspace.tableModel.seatFolder
local plateFolder = workspace.tableModel.plateFolder
local hum:Humanoid = c.Humanoid
randomSeat = seatFolder:GetChildren()[randomNo]
randomPlate = plateFolder:GetChildren()[randomNo]
if randomSeat:GetAttribute("occupied") == false then
c:PivotTo(randomSeat.CFrame* seatOFFSET)
wait()
randomSeat:Sit(hum)
if randomSeat.Occupant then
randomSeat:SetAttribute("occupied", true)
randomSeat:SetAttribute("playerName", randomSeat.Occupant.Parent.Name)
randomPlate:SetAttribute("playerName", randomSeat.Occupant.Parent.Name)
print(randomSeat.Name)
print(randomPlate.Name)
end
end
end)
end