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: Changing another block's material when touched

Previous Thread :: Next Thread 
Evilastro is not online. Evilastro
Joined: 11 Jul 2010
Total Posts: 531
02 Mar 2014 10:45 AM
Hey guys, so I'm making this mini wipeout thing, and I need to edit this script but I can't seem to get it right.

Anyway, what I need happening is instead of the colour changing, I want the material to change instead while the colour stays the same. Is that possible?

Below is the script
---------------------------------


function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
part.BrickColor = BrickColor.new(18)
end

script.Parent.Touched:connect(onTouch)
Report Abuse
Evilastro is not online. Evilastro
Joined: 11 Jul 2010
Total Posts: 531
02 Mar 2014 10:46 AM
Here's a prntscr of the script:

http:// prntscr (dot) com / 2x83ob
Report Abuse
SnowyKirby is online. SnowyKirby
Joined: 15 Jan 2013
Total Posts: 68009
02 Mar 2014 10:49 AM
function onTouch(part)
human = part.Parent:findFirstChild("Humanoid")
if human~=nil then
part.BrickColor = BrickColor.new(Br. yellowish orange)
end

script.Parent.Touched:connect(onTouch)
Report Abuse
Evilastro is not online. Evilastro
Joined: 11 Jul 2010
Total Posts: 531
02 Mar 2014 10:55 AM
I think I may have explained it wrong, by material I mean turning from Plastic into Corroded Metal. :P

So instead of having the brick change colour when it touches the brick the script is in, it will change it from plastic to Corroded Metal
Report Abuse
SnowyKirby is online. SnowyKirby
Joined: 15 Jan 2013
Total Posts: 68009
02 Mar 2014 10:56 AM
function onTouch(part)
human = part.Parent:findFirstChild("Humanoid")
if human~=nil then
part.Material = "CorrodedMetal"
end

script.Parent.Touched:connect(onTouch)
Report Abuse
juniorjfive is not online. juniorjfive
Joined: 05 Jan 2010
Total Posts: 671
02 Mar 2014 11:45 AM
local Part=script.Parent
local Materials={
'Brick',
'Concrete',
'CorrodedMetal',
'DiamondPlate',
'Fabric',
'Foil',
'Granite',
'Grass',
'Ice',
'Marble',
'Pebble',
'Plastic',
'Sand',
'Slate',
'SmoothPlastic',
'Wood'
}
Part.Touched:connect(function(Obj)
if Obj.Parent.ClassName=='Model'and Obj.Parent:findFirstChild('Humanoid')and Obj.Parent:findFirstChild('Torso')then
Part.Material=Materials[math.random(1,#Materials)]
return Part.Material
end
end)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
02 Mar 2014 11:50 AM
juniors got the right idea :3
otherwise,just set part.Material to a specific one
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