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

Script error. My surface guis won't change colors?

This script is suppost to pick random frames out of surfaceguis and change there color but for some reason it doesn't. Can anyone fix this issue??


local LetterTable = {
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
}


function Spread(color)
    for i,v in pairs(game.Workspace.danzflor.MidDanceFloor.Pads:GetChildren()) do
         local chosenPad = LetterTable[math.random(1,#LetterTable)]..math.random(1, 10)
         if chosenPad.ClassName~="Frame" then
            print(chosenPad)                
            return chosenPad.BackgroundColor3 == color
         end
    end
end


I remove the repeat but now it still won't change it's color.

2 comments

0

It's not working because you aren't calling the function...

0

I am not that dumb to not fire the function. I didn't added it as it's a simple script.

2 answers

✓ Accepted answer

If you would like to repeat the same function to loop you could use while loops

local LetterTable = {
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
}


function Spread(color)
    for i,v in pairs(game.Workspace.danzflor.MidDanceFloor.Pads:GetChildren()) do
         local chosenPad = LetterTable[math.random(1,#LetterTable)]..math.random(1, 10)
         if chosenPad.ClassName~="Frame" then
            print(chosenPad)                
            chosenPad.BackgroundColor3 = color
		wait(1)
         end
    end
end

while true do
	Spread(<set parameter>)
end

2 comments

0

That would crash the game, you are missing a wait() in the loop.

0

There is a wait in the function

Hey, I believe the issue here is that you are using return, which is stopping repeat.

However, I don't see your reason to use repeat at all.

From what I understand, you are trying to make a certain dance floor color with the color you want, so there is no reason for repeat at all.

Here you go:

local LetterTable = {
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
}


function Spread(color)
    for i,v in pairs(game.Workspace.danzflor.MidDanceFloor.Pads:GetChildren()) do
         local chosenPad = LetterTable[math.random(1,#LetterTable)]..math.random(1, 10)

         if chosenPad.ClassName~="Frame" then
            print(chosenPad)                
            chosenPad.BackgroundColor3 = color
         end
    end
end

Hope this helps you!

2 comments

0

I want it to repeat itself. When i do it gives me a error.

0

What error?

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