So I want to write a script that makes a player teleport to a seat. I have 16 seats and I want to make it so you get teleported randomly to one of them. But I want it not to teleport to a seat that is occupied How do I do this?
Assuming you have the seats grouped or in a set folder, etc.You'd use :getchildren()
local seats = workspace.Seats:GetChildren() -- puts all seats in a table local randomSeat = math.random(#seats) -- randomSeat is a number, don't need a loop since you only need 1. local selectedSeat = seats[randomSeat] -- this is your seat -- Finally, set the player CFrame, assuming you have defined player player.Character.HumanoidRootPart.CFrame = selectedSeat.CFrame