So, I am trying to make it so that players teleport randomly to the location of different bricks on my map. I have no idea on how to use random numbers with this, or if that has any correlation with what I am trying to do. What do I have to tweak to make this teleport them to random blocks?
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h ~= nil then t = h.Parent.Torso t.CFrame = CFrame.new(script.Parent.Parent.Part1.Position) end end script.Parent.Touched:connect(onTouched)
Thank you for your help, -Samson554
local RandomParts = {game.Workspace.Part1, game.Workspace.Part2, game.Workspace.Part3} --This is a table, It consists of all your parts that 1 of can be selected to be teleported to. function OnTouched(Hit) local Humanoid = Hit.Parent:FindFirstChild("Humanoid") if Humanoid then --Just a simple check to make sure that the hit is a player. Hit.Parent:MoveTo(RandomParts[math.random(1,#RandomParts)].Position) --If you want the Player to be teleported just above the part do the following after ].Positon, + Vector3.new(0, 5, 0) end end script.Parent.Touched:connect(OnTouched)
Not something I can solve, but you probably need to use math.random