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
 

Script works in solo but not on server

Previous Thread :: Next Thread 
Razorter is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
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 is not online. 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 is not online. 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 is not online. 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 is not online. NotAshley
Joined: 16 Jan 2014
Total Posts: 14257
28 Mar 2015 05:35 PM
Yay
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