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

How can i make players teleport in a specific area?

2 answers

✓ Accepted answer
wait(5)
for i, v in   pairs(game.Players:GetChildren()) do  v.Character.Torso.CFrame = CFrame.new(Vector3.new(50, 50, 50)) -- Change these coordinates to where you want the players to be teleported to
end


^^^Above answer only works once (since the player's character changes every time he/she dies)^^^

A solution to this is to grab that player's character everytime it respawns:

game.Players.PlayerAdded:connect(function(player) --grabs that specific player
	player.CharacterAdded:connect(function(character)
		repeat wait() until character.Torso.CFrame ~= nil -- to make sure that the torso exists
		character.Torso.CFrame = CFrame.new(workspace.Spawn.Position) + Vector3.new(0,10,0) --			set's the player's RESPAWN location
		repeat wait() until --will wait() until desired teleportation is called
		character.Torso.CFrame = CFrame.new(--Put desired position here<--)
		 character.Humanoid.Died:connect(function()
			wait(2)
			player:LoadCharacter() --actually respawns the player once he/she has died
		end
	end
end

Now if your wanting to teleport a player within a certain area (but not in an exact location), you'd use add this piece of code onto the one above:

character.Torso.CFrame = CFrame.new(math.random(min,max),math.random(min,max),math.random(min,max))

--Replace "MIN" and "MAX" with the minimum and maximum X,Y,Z coords

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