generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Random Teleport Scriptpiece [HELP]

Previous Thread :: Next Thread 
Sebery is not online. Sebery
Joined: 05 Apr 2014
Total Posts: 182
29 Sep 2015 01:44 AM
Hello ROBLOX Community. Today i have a Question. I want to make a Teleport System if something starts. Like if the "Starting in: (NUMBER)" hits 0 that every Player gets teleported. But now i want to make that the Script Piece teleports these Players to the Map. But every Player to a different Location. So there are 6 Players in the Game and the Game starts, i want that the 6 Players are getting teleportet into the Map. There are like 12 Bricks named "Spawn" and i want that the 6 Players are getting randomly placed to these Bricks. But i want too that they are not spawning at the same brick.

I have already a little piece of Code. If someone is nice enough to revamp it that it works with my Request, then please remake it: (ROBLOX+ Code Translation)

local players = game:GetService("Players"):GetPlayers()
if #players > 0 then
local randomplayer = players[math.random(1,#players)]
print(randomplayer.Name)
end


--the code below well teleport the players

local pos = Vector3.new(100,2,100)

local players = game:GetService("Players"):GetPlayers()
if #players > 0 then
for a= 1,#players do
if players[a].Character~=nil then
if players[a].Character:FindFirstChild("Torso")~=nil then
players[a].Character.Torso.CFrame = CFrame.new(pos)
end
end
end
end



Greetings, Sebery.
Report Abuse
tapuzi is not online. tapuzi
Joined: 05 Jul 2014
Total Posts: 162
29 Sep 2015 03:46 AM

i think you have to put the 'teleport-to-bricks' in a table and randomly pick a brick whose location will become the 'next-player-to-be-teleporteds' teleport destination. To ensure nobody else goes to that location you have to remove the relevent brick from the table before you teleport again. Depending on whether the map is messy or ordered you might want to remove the remaining 'teleport-to-bricks' after all players are teleported.


Where's my chips?
Report Abuse
tapuzi is not online. tapuzi
Joined: 05 Jul 2014
Total Posts: 162
29 Sep 2015 04:34 AM
might work :-

contestants = {}
for _, player in pairs(game.Players:GetPlayers()) do
if player and player.Character then
local humanoid = player.Character:WaitForChild("Humanoid")
if humanoid and humanoid.Health > 0 then
table.insert(contestants, player)
end
end
end

local spawns = {}
local stuff = game.workspace:GetChildren()
for_,item in pairs(stuff) do
if item.name == “Spawn”
table.insert(spawns.item)
end
end


for _, player in pairs(contestants) do
if player and player.Character and #spawns > 0 then
local torso = player.Character:WaitForChild("Torso")
local humanoid = player.Character:WaitForChild("Humanoid")
local spawnindex = math.random(1, #spawns)
local spawn = spawns[spawnindex]
if spawn and torso and humanoid then
.Health = 100
.WalkSpeed = 16
table.remove(spawns, spawnindex)
torso.CFrame = CFrame.new(spawn.Position + Vector3.new(0, 3, 0))
end
end
end

– cleanup
local stuff = game.workspace:GetChildren()
for_,item in pairs(stuff) do
if item.name == “Spawn”
item:remove()
end
end


Where's my chips?
Report Abuse
Sebery is not online. Sebery
Joined: 05 Apr 2014
Total Posts: 182
29 Sep 2015 04:39 AM
*gives chips*



Greetings, Sebery.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image