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 » Scripting Helpers
Home Search
 

Re: Making this work in play mode.

Previous Thread :: Next Thread 
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
20 Oct 2013 09:39 AM
This script works in solo mode, but not in play mode. Anyone know why?






while true do
wait(10)
players = game.Players:GetChildren()

for i = 1, 2 do
Chosen = players[math.random(1,#players)]
Chosen.Character:MoveTo(Vector3.new(-5, 43.6, -65.4))
local h = Instance.new("Hint",Chosen.PlayerGui)
local m = Instance.new("Message", Chosen.PlayerGui)
for i = 60,0,-1 do
wait(1)
h.Text = i
m.Text = i
end

for _,v in pairs (game.Players:GetChildren()) do
v.Character:BreakJoints()
h.Text = "Back to the lobby to strategies!"
m.Text = "Back to the lobby to strategies!"
wait(3.5)
m:Destroy()
h:Destroy()
wait(10)
end
end
end
Report Abuse
ProxyKiller is not online. ProxyKiller
Joined: 16 Oct 2013
Total Posts: 193
20 Oct 2013 09:42 AM
Because the character may not exist or something?
wiki.roblox.com
Report Abuse
TheRobloxian909 is not online. TheRobloxian909
Joined: 08 Aug 2013
Total Posts: 2444
20 Oct 2013 09:48 AM
I think it's this line:
Chosen = players[math.random(1,#players)]

Not sure.
Report Abuse
ProxyKiller is not online. ProxyKiller
Joined: 16 Oct 2013
Total Posts: 193
20 Oct 2013 09:52 AM
@TheRoblox
That line would work perfectly most of the time. On the safe side I would do,
Chosen = players:children()[math.random(1,#players)]
Report Abuse
TheRobloxian909 is not online. TheRobloxian909
Joined: 08 Aug 2013
Total Posts: 2444
20 Oct 2013 09:56 AM
Chosen = players:children()[math.random(1,#players)]

That is right, I think it was the error.
Report Abuse
TheRobloxian909 is not online. TheRobloxian909
Joined: 08 Aug 2013
Total Posts: 2444
20 Oct 2013 09:56 AM
Or possibly this:
local h = Instance.new("Hint",Chosen.PlayerGui)
local m = Instance.new("Message", Chosen.PlayerGui)
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
20 Oct 2013 09:57 AM
You mean :GetChildren?
Report Abuse
ProxyKiller is not online. ProxyKiller
Joined: 16 Oct 2013
Total Posts: 193
20 Oct 2013 09:58 AM
:children() is the same as :GetChildren()
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
20 Oct 2013 10:01 AM
@ProxyKiller, yes, why would I do that? That variable "Player" gets the children, so it's the same thing...
Report Abuse
TheRobloxian909 is not online. TheRobloxian909
Joined: 08 Aug 2013
Total Posts: 2444
20 Oct 2013 10:02 AM
I agree with thetacah, I think :GetChildren() means the select children.
Report Abuse
ProxyKiller is not online. ProxyKiller
Joined: 16 Oct 2013
Total Posts: 193
20 Oct 2013 10:02 AM
@thetacah
But :GetPlayers() is better.
http://wiki.roblox.com/index.php/GetPlayers
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
20 Oct 2013 10:05 AM
@, so now you say I should put :getplayers?
Report Abuse
ProxyKiller is not online. ProxyKiller
Joined: 16 Oct 2013
Total Posts: 193
20 Oct 2013 10:05 AM
It's what ever you want to put.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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