Hello, I’m working on a tool that changes color every time you pull it out. Below is my current script.
while true do
local candy = script.Parent
candy.BrickColor = BrickColor.Random()
end
Hello, I’m working on a tool that changes color every time you pull it out. Below is my current script.
while true do
local candy = script.Parent
candy.BrickColor = BrickColor.Random()
end
This loop is probably freezing your game?
It’ll keep changing your BrickColor over and over without stopping.
Just have the colour change lines without the loop play in the section of your tool script that plays when the tool is selected.
No the loop isn’t freezing the game. Currently it only randomly changes once and wont change again.
tool.Equipped:Connect(function()
script.Parent.BrickColor = BrickColor.Random()
end)
don’t use brickcolor.random() for candy, i don’t think you want a skin-colored candy…
just have an array of brick colors and use math.random() to index it.
For Future Reference
The Loop only runs once because it is most likely timing out.
When using loops you should use while wait() do
instead of while true do