Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is roblox scripting continuous or just repeats from 0?

I have made a dropper that drops ores, but i want the ores to be dropping with different colours, like first ore - red, second ore - purple, third ore - red, fourth ore - purple ect. when i tried putting something like this :

if(col == 1) then
 part.BrickColor = BrickColor.new("Really red")
 col = 0
finish = 1
end
if(finish == 0) then
if(col == 0) then
 part.BrickColor = BrickColor.new("Royal purple")
col = 1
end
end
finish = 0

There is a pattern for the colours, not random. in the droppers script, it just drops red coloured parts, where is the mistake i make??

Full Code:

while wait(1.75) do
local col = 1
local finish = 0
 local part = Instance.new("Part",game.Workspace)
 part.Name = "Ore"
 part.Size = Vector3.new(0.5, 0.5, 0.5)
 part.BottomSurface = 0
 part.TopSurface = 0
 part.Position = script.Parent.Position - Vector3.new(0, -0.5, 0)
if(col == 1) then
 part.BrickColor = BrickColor.new("Really red")
 col = 0
finish = 1
end
if(finish == 0) then
if(col == 0) then
 part.BrickColor = BrickColor.new("Royal purple")
col = 1
end
end
finish = 0
end
		local cash = Instance.new("NumberValue",part)
	cash.Name = "Cash"
	cash.Value = 100000000

4 comments

0

Can you please put this in a code block so it can be easily understood. When writing the question, there is a blue Lua button, click it and insert your code there.

0

And are you trying to make it random colours, or a set colour pattern?

0

done!

0

Use BrickColor.Random() if you're wanting random colors.

1 answer

You have col = 1 at the start of your while loop so every single time your while loop runs, it'll set col to 1 first. Simply move that just outside of the loop.

local col = 1
while wait(1.75) do
--Yada yada rest of script.

And that should do it.

This discussion is preserved as it was. New answers, comments, and votes are closed.