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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How to call all parts in a PLAYER in a single-player game?

Previous Thread :: Next Thread 
BlueJayManiac is not online. BlueJayManiac
Joined: 02 Jan 2015
Total Posts: 114
30 Jul 2017 06:09 PM
I'd like to make a variable that selects all the parts in a player that plays in my single-player game. Eventually, I would like to use this variable in a function that changes the body part's reflectance or transparency upon touching an object. Here's what I have so far:

player = game.Players:FindFirstChild()

However, for some reason, this doesn't work! All help is appreciated.


***Our greatest fear should not be of failure but of succeeding at things in life that don't really matter.***
Report Abuse
Rinem is online. Rinem
Joined: 05 Jan 2014
Total Posts: 255
30 Jul 2017 06:16 PM
I got you

Put this script in the brick that's gonna get touched to change that player's bodycolors/reflectance

script.Parent.Touched:Connect(function(part)

if part.Parent:FindFirstChild("Humanoid") then

playerchildren = part.Parent:GetChildren()

for i, v in pairs(playerchildren) do

if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("BasePart") then

v.Reflectance = 1 --//Or v.BrickColor = BrickColor.new("Whatever color you want") or use a color3.new

end
end
end)


dabbin' on the haters
Report Abuse
Scriptos is not online. Scriptos
Joined: 17 Jun 2008
Total Posts: 2900
30 Jul 2017 06:19 PM
function getAllParts(object, existing)
local list = existing or {};
for i,v in ipairs(object:GetChildren()) do
if (v:IsA("BasePart")) then
table.insert(list, v);
end;
getAllParts(v, list);
end return list end;

function setPropertyOfParts(list, property, value)
for i,v in ipairs(list) do
pcall(function()
v[property] = value;
end) end end;

script.Parent.Touched:connect(function(part)
if (part.Parent:FindFirstChild("Humanoid")) then
local characterModel = part.Parent;
setPropertyOfParts(getAllParts(characterModel), 'Transparency', .5);
end end);


This code will work with hats as well, or anything that is hidden inside something else within the character model.
Report Abuse
Rinem is online. Rinem
Joined: 05 Jan 2014
Total Posts: 255
30 Jul 2017 06:21 PM
Aaaand Scriptos takes the cake!


dabbin' on the haters
Report Abuse
Scriptos is not online. Scriptos
Joined: 17 Jun 2008
Total Posts: 2900
30 Jul 2017 06:25 PM
@Rinem; Sorry, I just figured that it'd be more useful if it also affected parts that might be hidden within hats or other objects inside of the character. 😂
Report Abuse
BlueJayManiac is not online. BlueJayManiac
Joined: 02 Jan 2015
Total Posts: 114
30 Jul 2017 08:04 PM
Thanks so much guys; I tested both and they work great!


***Our greatest fear should not be of failure but of succeeding at things in life that don't really matter.***
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