FANDOM


Brick2

IntroductionEdit

There are many ways to make a brick glow. This tutorial will explain the concept of making things glow using scripts.


The Reflectance GlowEdit

First, insert a brick, in Roblox Studio, then Insert a script inside this brick. Open up the script, then delete the text that says "Hello World!". Then, add the following text:

while true do
	for i=1, 9, 1 do
		-- Go up
		script.Parent.Reflectance = i * .1
		wait(.1)
	end
	for i=9, 1, -1 do
		-- Go down
		script.Parent.Reflectance = i * .1
		wait(.1)
	end
end

CommentsEdit

-- Go up and -- Go down are both preceded by double hyphens. Anything preceded by double hypens are ignored by the computer. Comments can help people by describing the purpose of a section of code, but the script will work just as fine with or without the comments.


LoopsEdit

for i=1, 9, 1 do
     script.Parent.Reflectance = i * .1
     wait(.1)
end

"i=1" means that the script is making a variable, which is, a value that can change as the script progresses. In this case, "i" will start at 1, and will increase everytime the "for loop" loops. It will go to 9 (notice the next statement, ", 9"), increasing in units of 1 (or, as in the second loop, decreasing by 1) and then stop the loop.

script.Parent.Reflectance = i * .1

This is just setting a value, but with a catch: we're setting it to a variable. Variables are assigned numerical values. (Note the "* .1". That's to make it ".1" when i is 1, and ".4" when i is 4, for example. A decimal is just another way to write a fraction.


This is how the loop can be reversed:

for i=9, 1, -1 do
		-- Go down
		script.Parent.Reflectance = i * .1
		wait(.1)
	end

The loop goes from the value of 9 to the value of 1, decreasing in units of 1 each time.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.