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: How to make a random player...

Previous Thread :: Next Thread 
JonathanW123 is not online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
13 Dec 2013 09:03 PM
How to make a random player's body parts turn the color black, and their transparency is 0.5.
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
13 Dec 2013 09:09 PM
First we have to choose a random player, to do this we will use :GetPlayers() to give us a table of every player.

plrs = game.Players:GetPlayers()

We want to choose a random player, so we generate a random number between 1, and how many players there are (#plrs gives us how many players we have)

randomNumber = math.random(1,#plrs)

Now we use this random number to give us a victim!

for i,v in pairs(game.Players:GetPlayers()) do
if i == randomNumber then

So now we have our victim, let's change their properties!

for _,v in pairs(v.Character:GetChildren()) do
if v:IsA("Part") then
v.BrickColor = BrickColor.new("Black")
v.Transparency = .5
end
end

Okay their properties are changed, time to tie up loose ends (woo I made a pun) and put this all together.

plrs = game.Players:GetPlayers()
randomNumber = math.random(1,#plrs)

for i,v in pairs(game.Players:GetPlayers()) do
if i == randomNumber then
for _,v in pairs(v.Character:GetChildren()) do
if v:IsA("Part") then
v.BrickColor = BrickColor.new("Black")
v.Transparency = .5
end
end
end
end


--[Territory Conquest Developer, Valerian Studios Developer, Business Casual Narwhal Moai. ]]--
Report Abuse
adammthomas2000 is not online. adammthomas2000
Joined: 24 Feb 2013
Total Posts: 454
13 Dec 2013 09:13 PM
^
Be aware of HumanoidRootJoints. It's those blue blocks that constantly appear when using Kohl's Admin Commands. Unless you want those boxes appearing in-game, do this:



Wherever it says

if v:IsA("Part") then

replace with

if v:IsA("Part") and v.Name ~= "HumanoidRootPart" then


That way, it skips over the HumanoidRootPart when changing properties.
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
13 Dec 2013 09:15 PM
...
So ROBLOX finally got around to adding in Animations?

I've been busy playing League of Legends lately, and haven't done anything in studio in... quite a long time.

Do add the exception for the root part, as it seems to be default transparent anyways and won't affect anything you're wanting to do!

--[Territory Conquest Developer, Valerian Studios Developer, Business Casual Narwhal Moai. ]]--
Report Abuse
adammthomas2000 is not online. adammthomas2000
Joined: 24 Feb 2013
Total Posts: 454
13 Dec 2013 09:19 PM
^
Just saying, if someone is wearing a 2.0 package for example, then the blocky HumanoidRootPart suddenly appears overtop their package and can get quite annoying. You have no idea how many times I've reset my character over that kind of glitch XD

Oh, and yeah they finally added animations. And SurfaceGuis too. I'm going to mess around with them later.
Report Abuse
JonathanW123 is not online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
13 Dec 2013 09:20 PM
Guys, I need you to add onto that script. It also needs to remove their SHIRT and PANTS and HATS. My head and all my skin is still the color of tan, it's not BLACK
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
13 Dec 2013 09:25 PM
Heads use meshes I believe... let me open studio really quickly.

Haha, I opened my testing for my survival game and found out that I forgot to disable loot spawning, so now there is like eight hundred rocks and sticks lying around everywhere. Fantastic.

Anyways:

add these

if v:IsA("Part") and v.Name ~= "HumanoidRootPart" then
v.BrickColor = BrickColor.new("Black")
v.Transparency = .5
elseif v:IsA("Hat") then
v:Destroy()
elseif v:IsA("Shirt") then
v:Destroy()
elseif v:IsA("Pants") then
v:Destroy()
end

as for your head not turning colors, they should, maybe Black isn't a valid brickcolor lel


--[Territory Conquest Developer, Valerian Studios Developer, Business Casual Narwhal Moai. ]]--
Report Abuse
adammthomas2000 is not online. adammthomas2000
Joined: 24 Feb 2013
Total Posts: 454
13 Dec 2013 09:25 PM
plrs = game.Players:GetPlayers()
randomNumber = math.random(1,#plrs)
for i,v in pairs(game.Players:GetPlayers()) do
if i == randomNumber then
for _,v in pairs(v.Character:GetChildren()) do
if v:IsA("Part") and v.Name ~= "HumanoidRootPart" then
v.BrickColor = BrickColor.new("Black")
v.Transparency = .5
elseif v:IsA("Hat") or v:IsA("Hat") or v:IsA("Hat") then
v:destroy()
end
end
end
end

When you respawn them do something like:

game.Players.Player1:LoadCharacter()
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
13 Dec 2013 09:26 PM
yeah it def should turn black, "Black" is a valid brickcolor

--[Territory Conquest Developer, Valerian Studios Developer, Business Casual Narwhal Moai. ]]--
Report Abuse
JonathanW123 is not online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
13 Dec 2013 09:29 PM
Tried both. Didn't remove the hat, or the shirt, or the pants!
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
13 Dec 2013 09:30 PM
Are you sure you're running the script?

--[Territory Conquest Developer, Valerian Studios Developer, Business Casual Narwhal Moai. ]]--
Report Abuse
JonathanW123 is not online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
13 Dec 2013 09:30 PM
I'm in Test Solo(F6)
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
13 Dec 2013 09:31 PM
Then you need to disable and re-enable the script.

Click on the script and it's one of its properties.

--[Territory Conquest Developer, Valerian Studios Developer, Business Casual Narwhal Moai. ]]--
Report Abuse
adammthomas2000 is not online. adammthomas2000
Joined: 24 Feb 2013
Total Posts: 454
13 Dec 2013 09:32 PM
I'd assume the script is starting before anything loads... If you are running this script just for testing purposes, then add a wait(5) at the beginning.

If you intend to do this for an actual game, use WaitForChild()s.
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
13 Dec 2013 09:34 PM
That is if you're using
game.Players.PlayerAdded:connect(function()
--stuff
end)

If you're just using it for like an admin commands kinda thing, you don't need to use WaitForChild

--[Territory Conquest Developer, Valerian Studios Developer, Business Casual Narwhal Moai. ]]--
Report Abuse
JonathanW123 is not online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
13 Dec 2013 09:35 PM
Guys, I plan to do this in a GameScript, so after wait(10), it will play.
Report Abuse
JonathanW123 is not online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
13 Dec 2013 09:36 PM
I added wait(5)

Removed hats, didn't remove shirt & pants
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