Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making color come back with a touch on a cube?

Asked by 7 years ago

I am really new to scripting and was wondering how I would be able to make it so that when you touch the brick it would add some saturation?

0
I know you are new here, but next time, try to attempt some coding yourself before asking here. We will be more likely to help if you do so. Also, here is an idea: Connect the "Touched" event to a function that changes the brick's saturation. http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched starlebVerse 685 — 7y

1 answer

Log in to vote
0
Answered by
Pengdoo 26
7 years ago

You can use the Touched event.

First you need to add a script inside your brick.

Next you need to program the script. So first, you've gotta tell the script which part it is you want to change its color so the first line should be :

local brick = script.Parent --it's script.Parent because you've put the script inside your brick.

Now we need to add the Touched event.

local brick = script.Parent
brick.Touched:connect(function()

end)

Now we need to actually do something when the brick is actually touched. In this case, as you've stated.... increase saturation.... now I personally don't know how to do that, instead I'll make the script so that it changes the brick's color to a random color. You can change it to however you want to be.

local brick = script.Parent
brick.Touched:connect(function()
    brick.BrickColor = BrickColor.Random() --change BrickColor.Random() if you want
end)

And there we go! Now everytime you touch the brick the color of the brick changes to a random color!

Here is the link to the wiki where you can explore all the BrickColor functions : http://wiki.roblox.com/index.php?title=BrickColor

Also, as CStarLam said, try to attempt some coding yourself and do some rearch before asking anything. We're more likely to help if you do so.

Have fun! ~Pengdoo

Ad

Answer this question