help with changing the color of an entity on every use

what i am trying to do is every time a player hits the use key on the entity it changes to a different color.
but for some reason it runs through the whole entire code and picks the color on the bottom of the code and wont change. it just stays with the color red .

[lua]
function ENT:Use ( ply )
if self.Entity:GetColor(0,0,255,255) then – Blue
print(“0”)
self:SetColor(255,255,255,255) – White

end

if self.Entity:GetColor(0,255,0,255) then --Green
print(“1”)
self:SetColor(0,0,255,255) – Blue

end

if self.Entity:GetColor(255,0,0,255) then – Red
print(“2”)
self:SetColor(0,255,0,255) – Green

end

if self.Entity:GetColor(255,255,255,255) then – White
print(“3”)
self:SetColor(255,0,0,255) – Red

end

end
[/lua]

what i was trying to do was since i have the entity to Initialize the color white was to let it go through the code and let it pick the color starting at the bottom on up.
white to red then red to green then green to blue then blue to white

any ideas to make something like this to work.

[lua]
ENT.ColorNum = 1
ENT.Colors = {Color(0,0,255,255),
Color(0,0,255,255),
Color(0,255,0,255),
Color(255,0,0,255),
Color(255,255,255,255),
}
function ENT:Use ( ply )
self.ColorNum = self.ColorNum + 1
if self.ColorNum > #self.Colors then self.ColorNum = 1 end
self.SetColor(self.Colors[self.ColorNum].r,self.Colors[self.ColorNum].g,self.Colors[self.ColorNum].b,self.Colors[self.ColorNum].a)
end
[/lua]

there’s probably a better way to do this, but this should work unless I’m being stupid again

when i try it . it say

[lua]@lua\includes\extensions\entity.lua:116] bad argument #1 to ‘setColor’ (Entity expected, got number)[/lua]

line:116 is

[lua]function meta:SetColor( r, g, b, a )
if ( type( r ) == “table” ) then setColor( self, r.r, r.g, r.b, r.a ) return end
setColor( self, r, g, b, a ) --line:116
end[/lua]

[

[lua]ENT.ColorNum = 1
ENT.Colors = {Color(0,0,255,255),
Color(0,0,255,255),
Color(0,255,0,255),
Color(255,0,0,255),
Color(255,255,255,255),
}
function ENT:Use ( ply )
self.ColorNum = self.ColorNum + 1
if self.ColorNum > #self.Colors then self.ColorNum = 1 end
self.SetColor(self.Colors[self.ColorNum].r,self.Colors[self.ColorNum].g,self.Colors[self.ColorNum].b,self.Colors[self.ColorNum].a)
end[/lua]

problem is right here, [lua]self.SetColor[/lua]
Change the . to a :

Wow thanks guys .I got another question . ( ent.color ) is that called a meta table?

deerrpp

I am just not doing good this week, sorry OP

yo dont need to be sorry amkoc you helped me .and i thank you very much in taking your time effort to do so