Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

If I use a single teleport pad, can I tp people to multiple other spots?

Asked by
0wuv 0
5 years ago

As I'm making a game, I need to make a teleport pad, but that teleport pad should teleport players to random spots within a certain area. I know how to tp a player from the tp pad to one single spot, but don't know how to randomize where they get teleported to if they touch the same block. My script looks like this;

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild('Humanoid')then
        hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-1396.246, 21.25, 580.245)
    end
end)

So, anyone please explain how to tp people from one teleport pad to multiple other blocks

1 answer

Log in to vote
0
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago

Yes, have a table containing all the possible spots:

possibleLocations = {game.Workspace.Spot1, game.Workspace.Spot2} 

inside your for loop pick a random position by saying

pickedLocation = possibleLocations[math.random(1,#possibleLocations)]

then set the characters cframe to picked locations CFrame.

Ad

Answer this question