Razorter
|
  |
| Joined: 25 Nov 2010 |
| Total Posts: 306 |
|
|
| 28 Mar 2015 04:53 PM |
while wait(5) do local Plrs = game.Players:GetPlayers() -- Add all players to Plrs table Plr1 = Plrs[math.random(1,#Plrs)] -- Get a player, this player is defined under Plr1 plrTorso = Plr1.Character:FindFirstChild("Torso") script.Parent.Position = plrTorso.Position+Vector3.new(0,5,0) script.Parent.Anchored = false wait(2.5) script.Parent.CanCollide = false wait(0.5) script.Parent.Anchored = true script.Parent.Position = plrTorso.Position+Vector3.new(0,50,0) script.Parent.CanCollide = true end
This is a script in a part. It teleports the part to a random player in the server (It should but doesn't).
Funse wrote this script earlier. |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 28 Mar 2015 04:55 PM |
| When you test online, hit F9 and look at the server console. Post the error here. |
|
|
| Report Abuse |
|
|
Razorter
|
  |
| Joined: 25 Nov 2010 |
| Total Posts: 306 |
|
|
| 28 Mar 2015 05:01 PM |
Doesn't look like there is any errors related to the script. Or I might be wrong. |
|
|
| Report Abuse |
|
|
Razorter
|
  |
| Joined: 25 Nov 2010 |
| Total Posts: 306 |
|
|
| 28 Mar 2015 05:03 PM |
Wait I see something. Workspace.CompanionCube.script:3: bad arguement #2 to 'random' (interval is empty) |
|
|
| Report Abuse |
|
|
Razorter
|
  |
| Joined: 25 Nov 2010 |
| Total Posts: 306 |
|
|
| 28 Mar 2015 05:04 PM |
bump
CompanionCube is the part the script is in. |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 28 Mar 2015 05:06 PM |
| It's trying to select a random player before anyone is in the server yet. Try making sure at least 1 player is in-game before running the code. |
|
|
| Report Abuse |
|
|
Razorter
|
  |
| Joined: 25 Nov 2010 |
| Total Posts: 306 |
|
|
| 28 Mar 2015 05:11 PM |
Alright soo, what I'm trying isn't working. How can I do this is a way that works? |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 28 Mar 2015 05:16 PM |
while wait(5) do local Plrs = game.Players:GetPlayers() -- Add all players to Plrs table if Plrs > 0 then Plr1 = Plrs[math.random(1,#Plrs)] -- Get a player, this player is defined under Plr1 plrTorso = Plr1.Character:FindFirstChild("Torso") script.Parent.Position = plrTorso.Position+Vector3.new(0,5,0) script.Parent.Anchored = false wait(2.5) script.Parent.CanCollide = false wait(0.5) script.Parent.Anchored = true script.Parent.Position = plrTorso.Position+Vector3.new(0,50,0) script.Parent.CanCollide = true end end |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 28 Mar 2015 05:17 PM |
Sorry, messed up. You use the # operator to check the size of the table.
while wait(5) do local #Plrs = game.Players:GetPlayers() -- Add all players to Plrs table if Plrs > 0 then Plr1 = Plrs[math.random(1,#Plrs)] -- Get a player, this player is defined under Plr1 plrTorso = Plr1.Character:FindFirstChild("Torso") script.Parent.Position = plrTorso.Position+Vector3.new(0,5,0) script.Parent.Anchored = false wait(2.5) script.Parent.CanCollide = false wait(0.5) script.Parent.Anchored = true script.Parent.Position = plrTorso.Position+Vector3.new(0,50,0) script.Parent.CanCollide = true end end |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 05:18 PM |
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) repeat wait() until game.Workspace:FindFirstChild(character) do local Plrs = game.Players:GetPlayers() -- Add all players to Plrs table local Plr1 = Plrs[math.random(1,#Plrs)] -- Get a player, this player is defined under Plr1 local plrTorso = Plr1.Character:FindFirstChild("Torso") script.Parent.Position = plrTorso.Position+Vector3.new(0,5,0) script.Parent.Anchored = false wait(2.5) script.Parent.CanCollide = false wait(0.5) script.Parent.Anchored = true script.Parent.Position = plrTorso.Position+Vector3.new(0,50,0) script.Parent.CanCollide = true end end) end)
#໓นrŞt (RAP:586,192 - R$156,832 - Tx13,180) [British. Tea slurper. -slurps tea-] |
|
|
| Report Abuse |
|
|
Razorter
|
  |
| Joined: 25 Nov 2010 |
| Total Posts: 306 |
|
|
| 28 Mar 2015 05:26 PM |
Nope, those don't even work in solo. I tried them on server too. |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 28 Mar 2015 05:30 PM |
I messed up again by putting the # operator in the wrong spot. I'm on a roll today.
Try this:
while wait(5) do local Plrs = game.Players:GetPlayers() -- Add all players to Plrs table if #Plrs > 0 then Plr1 = Plrs[math.random(1,#Plrs)] -- Get a player, this player is defined under Plr1 plrTorso = Plr1.Character:FindFirstChild("Torso") script.Parent.Position = plrTorso.Position+Vector3.new(0,5,0) script.Parent.Anchored = false wait(2.5) script.Parent.CanCollide = false wait(0.5) script.Parent.Anchored = true script.Parent.Position = plrTorso.Position+Vector3.new(0,50,0) script.Parent.CanCollide = true end end |
|
|
| Report Abuse |
|
|
Razorter
|
  |
| Joined: 25 Nov 2010 |
| Total Posts: 306 |
|
|
| 28 Mar 2015 05:33 PM |
Yes! Thank you this works.
You can see what happens here: http://www.roblox.com/Elevator-place?id=197224718
It will be pretty obvious what part it is. |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
| |
|