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

Teleporting to random parts on the Map not working?

I'm having some trouble with a teleportation script. I'm using the CFrame.new method to teleport players to random parts of the map.

for i = 10,0,-1 do 
    timeText.Text = "Next round in: "..i 
    wait(1) 
if i == 0 then
	timeText.Text = "Choosing map..."
wait(1)
	Maps = game.ServerStorage.Maps:GetChildren()
	Map = Maps[math.random(1,#Maps)]:Clone()
	Map.Parent = game.workspace 
	timeText.Text = "Map chosen: "..Map.MapName.Value.." by "..Map.MapCreator.Value.."."
	wait(2)
	timeText.Visible = false
	TeleportPart = Map.TeleportPart
for i, player in pairs(game.Players:GetPlayers()) do
	player.Character.Torso.CFrame = TeleportPart + Vector3.new[math.random(TeleportPart.Position)]
end
end
end
end

This is what I got in the output:

14:52:45.961 - Players.Player1.PlayerGui.Intermission.LocalScript:29: bad argument #1 to 'random' (number expected, got Vector3)>

EDIT: Added the entire script

1 comment

0

Line 15 on here is your problem. You can't give math.random a position.

1 answer

I'm not sure where you want to teleport the player relevant to the part, but this should help.

player.Character.Torso.CFrame = TeleportPart + Vector3.new[math.random(TeleportPart.Position)]
--Should look something like this
player.Character.Torso.CFrame = TeleportPart + Vector3.new[math.random(-10, 10), math.random(0, 10), math.random(-10, 10)]

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