Im working on a night club and Im always seeing these games with those fancy, detailed coded ones that have like different movements and stuff. Ive been trying to research how to do it but Im still a beginner coder. Any ideas?
Do note that this is not a requesting site, but we can show you through on how to accomplish this.
First we want to start this with a loop, in this circumstance, we'll use a while
loop, this loop continues looping until it's condition is nil or changed.
while condition do
while
loop.A while loop does come with some responsibilities, and consequences. First, lag. A while loop can accumulate some lag in your game if not using FE. Second, crashes. Loops can cause crashes, especially while
loops, if not used without a wait
() function.
while true do wait(.5) end
while true do script.Parent.BrickColor = script.Parent.BrickColor.Random() wait(.5) end
If you want to prevent huge lag( or copying one script at a time), I suggest using a generic loop with for
as it's iterator, and a function to receive the values, pairs()
.
local danceparts=model:GetChildren() while true do for index, value in pairs(danceparts) do value.BrickColor = value.BrickColor.Random() wait(.5) end end
I modified some code for you, Enjoy!
-- Put this in the brick you want to switch colors!
while true do script.Parent.Color = Color3.new(math.random(), math.random(), math.random()) wait(2.0) end