Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i teleport a player to a seat?

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?

1 answer

✓ Accepted answer

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

1 comment

0

Thank you so mutch it worked! <3 But if sombody is sitting in 15 of the 16 seats. Will it teleport me to the last seat?

This discussion is preserved as it was. New answers, comments, and votes are closed.