Why arent my scripts working?

Greeting! I made a script that should change the color of the object every two seconds. The problem is it doesn’t work, please help if you can see what the problem is.

  1. **What do you want to achieve? I want to make objects turning their color every 2 seconds.

  2. **What is the issue? It dosent work, but scripts are fine.

  3. **What solutions have you tried so far? I searched it on internet, but nothing.

Here are the scripts.

local Part = script.Parent

Part.Color = Color3.fromRGB (255, 0, 0)
wait (2)
Part.Color = Color3.fromRGB (0, 255, 0)
wait (2)

Is this the whole script? (30charrrrrrrs)

1 Like

Yes, simplest scripts on this platform. But it still dosent work…

I see you want it changing every 2 seconds, but you only have it set to change twice. You will need to put them in some kind of loop if you want it changing every 2 seconds.

1 Like

Hmm, I have no scripting knowledge. Even for this script :joy:. Maybe add end at the end of the script or, write out this script without adding variables.

1 Like

Do you mean command | while true do | ??

1 Like

Yes you can put it in a while true do loop and it should change every 2 seconds. It will only go between those two colors though.

1 Like

Alright, I will try that. Thank you for the time.

I can’t tell if that’s a typo or that’s your actual script.

You can’t have a space between the Color3.fromRGB and the (0, 255, 0). It has to be all in one straight line.
Color3.fromRGB(0, 255, 0)

While it makes it look more clean, you actually can have a space between them and it still does the required task

You could add a while true do and then you have some kind of identifier to know its either red or green.

Try naming a variable called red and make the value of it be true so inside the while loop you add this:

if red == true then
       -- If the part is going to be red then
      Part.Color = Color.fromRGB(255,0,0)
      red = false
elseif red == false then
      Part.Color = Color.fromRGB(0,255,0)
      red = true
end

This will loop and make the part become red or green depinding of the red variable. So later this identifier’s end you put a wait(2) for the cooldown.

Can you atleast tell us what the problem is, any errors pop up in the output???

Lua isn’t that strict about whitespace.