Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

For loop doesn't want to run regardless of what I do?

Asked by 3 years ago
Edited 3 years ago
-- This script is stored in ServerScriptService
local ColorFloor = game.Workspace.ColorFloor:WaitForChild("ColorPlate")
local ColorFloorChildren = ColorFloor:GetChildren()

local function ColorChange()
    print("ColorChange() ran")
    for i, v in ipairs(ColorFloor:GetChildren()) do
        print("For loop ran")
        local randomnumber = math.random(1,1)
        print(randomnumber)
        if randomnumber == 1 then
            v.Color = Color3.FromRGB(0, 0, 0)
        elseif randomnumber == 2 then
            v.Color = Color3.FromRGB(255, 255, 255)
        elseif randomnumber == 3 then
            v.Color = Color3.FromRGB(255, 0, 0)
        elseif randomnumber == 4 then
            v.Color = Color3.FromRGB(0, 255, 0)
        elseif randomnumber == 5 then
            v.Color = Color3.FromRGB(0, 0, 255)
        end
    end
end

ColorChange()
  • Maybe the code itself is what is breaking it. But, I'm pretty sure it is some type of logistics that I'm doing wrong. But, regardless my function will run just fine. My first print will print to the console. But, for some reason the for loop doesn't want to run. Hoping someone can see an issue with the code.
0
I see its a disco floor type of code They would all just be 1 cause the minimum is 1 and the maximum is 1 so it would all just be completely black, try setting it to (1,5) kepiblop 124 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

I ended up fixing my issue by getting rid of WaitForChild()... I don't know why or how this broke my code. But, I'm not going to question it

Ad

Answer this question