Forum > Coding >

trying to make a part switch colours in a loop but it's not working

Posts: 5

Threads: 2

Joined: Feb, 2022

Reputation: 0

Posted

Fixed

 

first off, i'm going to say this : 

i'm very new to lua so please do not bully me.

now that we got that out of the way, let's get into the topic.

 

for some reason this code isn't working when i'm trying to get it to loop change colours.

game.Workspace.brick.Material = Enum.Material.Neon

while true do
	game.Workspace.house.brick.Color = Color3.fromRGB(255,0,0)
	wait(0.1)
	game.Workspace.house.brick.Color = Color3.fromRGB(255,165,0)
	wait(0.1)
	game.Workspace.house.brick.Color = Color3.fromRGB(255,255,0)
	wait(0.1)
	game.Workspace.house.brick.Color = Color3.fromRGB(0,128,0)
	wait(0.1)
	game.Workspace.house.brick.Color = Color3.fromRGB(0,255,255)
	wait(0.1)
	game.Workspace.house.brick.Color = Color3.fromRGB(0,0,255)
	wait(0.1)
	game.Workspace.house.brick.Color = Color3.fromRGB(255,0,255)
	wait(0.1)
end

if i'm not mistaken, this should be working?

if anything, i put it in ServerScriptService but i don't think that's the problem since my printing script is working there.

video : https://streamable.com/w57yqj

  • 0

notdistantt#6774

superleito1_1

i like chicken nuggets

vip

Posts: 55

Threads: 15

Joined: Jun, 2022

Reputation: 4

Replied

brick's colors are calculated in BrickColor, not Color3, so it should be like this:

game.Workspace.house.brick.BrickColor = BrickColor.new("your color")
  • 0

"""""""professional""""""" at code

Posts: 5

Threads: 2

Joined: Feb, 2022

Reputation: 0

Replied

@_realnickk sorry but i'm like REALLY new to game scripting so i don't know what indexing is.

 

I appreciate your advice of removing game and only putting workspace. I've watched one Roblox lua video by AlvinBlox from 3 years ago and that's it.

How could i go about indexing the house model?

  • 0

Added

@_realnickk i just fixed it by putting it out of house, i don't need all that trouble

 

and about the cleaning up code thing, i'll try to learn it later but for now i'm just trying to do it and not really caring about the appearance of the script.

 

Thank you!

  • 0

notdistantt#6774

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )