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

Not all colour are changing at the same time,why?

Asked by
Gigaset39 111
2 years ago
Edited 2 years ago

Hello Scripters :D , i have created a part that when u touch the switch you change the colour of 12 part in a folder and 12 parts in another folder ,so i use this this script:

Changer = script.Parent
local t=0
local f = 0
Changer.ClickDetector.MouseClick:Connect (function()

while true do
for _, Green in pairs(workspace.Game.Lobby.Structure.WindowFrame:GetChildren()) do
    Green.BrickColor = BrickColor.new("Really red")
    wait(f)
end
for _, Green in pairs(workspace.Game.Lobby.Structure.YellowMarks:GetChildren()) do
    Green.BrickColor = BrickColor.new("Really red")
    wait(f)
end
wait(t)

    for _, Green in pairs(workspace.Game.Lobby.Structure.WindowFrame:GetChildren()) do
        Green.BrickColor = BrickColor.new("Deep orange")
        wait(f)
end
for _, Green in pairs(workspace.Game.Lobby.Structure.YellowMarks:GetChildren()) do
    Green.BrickColor = BrickColor.new("Deep orange")
    wait(f)
end ..................

the problem is, that when i click the switch, the parts change the colour,but not instantly... like all wait is set to 0,why it doesent do that instantly?

1 answer

Log in to vote
1
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

it doesnt do that instantly because

wait(0)

is the same with wait 0.03 seconds, because that is the minimum the wait can do

if you want to do it instantly, try making all wait(f) like this

if f ~= 0 then
    wait(f)
end

this means

  • if f is zero it will do nothing (no wait)
  • if f is not zero it will do wait(f)
0
your right, thanks. Gigaset39 111 — 2y
Ad

Answer this question