The title says it all, how do you make something keep going until it reaches to a certain thing, so like if I keep pressing a button and the part keeps changing colors it stops changing colors when it becomes yellow or green idk, I've tried looking at loops and stuff but I don't really know if that option works.
Hey man, seems like you talking about loops? For something like your example you would want to do something like:
local button = gui.button local part = workspace.part -- Wait for mouse click button.MouseButton1Click:connect(function() -- loop the code but break the loop once it has gone red while part.BrickColor ~= BrickColor.new("Bright red") do -- if its not red run this code part.BrickColor = BrickColor.random() -- in loops always remember to put a wait otherwise the game will freeze wait(1) end -- if the color turns red then the loop will stop yielding and the rest of the code will run print('The brick is now red') end)
This was more giving code than an explanation, so for mroe advanced stuff read mroe about loops here: http://wiki.roblox.com/index.php?title=Loops
Closed as Non-Descriptive by cabbler, BlackOrange3343, and TheHospitalDev
This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.
Why was this question closed?