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: Choose random player not functioning

Previous Thread :: Next Thread 
eminem4roblox is not online. eminem4roblox
Joined: 03 Oct 2012
Total Posts: 2966
29 Aug 2014 11:53 PM
I want it to choose a random play and give it 150 health and 20 walkspeed. Im pretty sure this is the part of the script that needs fixing.

-- Created by eminem4roblox

p = game.Players:Children()
crimonal = p[math.random(1,#p)] -- Get's a random player

wait(1)
print ("Crimonal has been chosen!")

crimonal.Humanoid.Health = 150
crimonal.Humanoid.MaxHealth = 150
crimonal.Humanoid.WalkSpeed = 20

print ("Crimonal has been given powers!")
Report Abuse
baheeg is not online. baheeg
Joined: 19 Jul 2010
Total Posts: 72846
29 Aug 2014 11:55 PM
First
:Children() is deprecated
Use :GetPlayers() or :GetChildren()
Then tell us what the output says
Report Abuse
jknite is not online. jknite
Joined: 30 Nov 2007
Total Posts: 614
29 Aug 2014 11:56 PM
p = game.Players:GetChildren() -- forgot get
crimonal = p[math.random(1,#p)] -- Get's a random player -- I haven't used this method for it, but seems like it should work

wait(1)
print ("Crimonal has been chosen!")

crimonal.Humanoid.Health = 150
crimonal.Humanoid.MaxHealth = 150
crimonal.Humanoid.WalkSpeed = 20

print ("Crimonal has been given powers!")
Report Abuse
eminem4roblox is not online. eminem4roblox
Joined: 03 Oct 2012
Total Posts: 2966
29 Aug 2014 11:57 PM
Still doesn't work. The output is:

00:57:13.299 - Auto-Saving...
00:57:15.146 - Workspace.Script:4: bad argument #2 to 'random' (interval is empty)
00:57:15.148 - Script 'Workspace.Script', Line 4
00:57:15.150 - Stack End
Report Abuse
baheeg is not online. baheeg
Joined: 19 Jul 2010
Total Posts: 72846
30 Aug 2014 12:00 AM
Place a wait() above
Report Abuse
eminem4roblox is not online. eminem4roblox
Joined: 03 Oct 2012
Total Posts: 2966
30 Aug 2014 12:02 AM
Still says the same thing
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
30 Aug 2014 12:12 AM
If this is a script that runs at launch, add this to the beginning:

repeat wait() until #game.Players:GetChildren() > 0
Report Abuse
eminem4roblox is not online. eminem4roblox
Joined: 03 Oct 2012
Total Posts: 2966
30 Aug 2014 07:51 AM
Okay so now it says crimonal has been chosen but the humanoid is not a member of the player...
Here's the output:

Crimonal has been chosen!
08:49:21.091 - Humanoid is not a valid member of Player
08:49:21.132 - Script 'Workspace.Script', Line 10
08:49:21.133 - Stack End
Report Abuse
GuestOfChaos is not online. GuestOfChaos
Joined: 01 Sep 2013
Total Posts: 71
30 Aug 2014 07:54 AM
You defined 'crimonal' as the player Crimonal.
The humanoid is in the player's character...

so..

criminol.Character.Humanoid.MaxHealth = 150

--Blablabla
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