Trying to give a player a plate

hello! im trying to give a player a plate. would this be the most efficient way of doing it? so if a player sits in chair 1, the attribute playerName in the seat and the plate will have the players name.

ty 4 the help!

			if randomSeat.Name == "chair1" then
				plate = workspace.plate1
				plate:SetAttribute("playerName", randomSeat.Occupant.Parent.Name)
			end
			
		elseif randomSeat.Name == "chair2" then
			plate = workspace.plate2
			plate:SetAttribute("playerName", randomSeat.Occupant.Parent.Name)
		end	

and then continue up to chair 20…


image
image

1 Like

You can just do a loop:

local amountofchairs = 20

for i = 1, amountofchairs do
     local chair = "chair"..tostring(i)
     local plate = "plate"..tostring(i)
     print(chair, plate)
end
1 Like

ty 4 the response! after re reading my post i explained it poorly.

basically if a player sits on say seat 1. the players name will be stored in the seat 1 and plate 1 but i cant really get it to work:

so far it stores the player name in the seat but i cant get it to do the plate:

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 hum:Humanoid = c.Humanoid
		randomSeat = seatFolder:GetChildren()[math.random(1, #seatFolder: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)
				print(randomSeat.Name)
	
			end
		end	
	end)
end
1 Like