Colour Change, For One Team Only

Hi, I want to change the colour of an entity, but only for an specific team (Traitors, From TTT Gamemode)

I Tried:

[lua]function Meh()
if ply:IsTraitor() then
self:SetColor(Color(255, 0, 0, 255))
end
end
[/lua]
[lua]
if IsValid(ply) and ply:IsActiveTraitor() then
self:SetColor(Color(255, 0, 0, 255))
end[/lua]

Nothing Worked… Any help? (No lua errors on console)

How are you running this?

It’s located on gamemodes/terrortown/entities/entities/ttt_weapon/shared.lua

It Loads Like a TTT Weapon, and The weapon code Works, only the “Colour Change” Part doesn’t.

IIRC you want to change the entity clientside not serverside, so it won’t affect the items ‘actual’ color on the server, but on the client. I’m not sure how to explain this correctly but there you go.

Try with

[lua]
for k, v in pairs(player.GetAll()) do
if v:IsTraitor() then
v:SetColor(Color(255, 0, 0, 255))
end
end
[/lua]

Set it in a function and use a Hook.

Wait, You want to change the colour of the traitors? That would make it a Counter-Strike Deathmatch.

Thanks for the help, I’ll test that.

No, I Don’t want to change the Traitor colour, I want to change the entity colour…

I Tested the code on Other entity (Health Station)

I Tryed:
[lua]
local function ChangeColour()
for k, v in pairs(player.GetAll()) do
if v:IsTraitor() then
ENT.TargetIDHint = {
name = “Test”
};
end
end
end
end
[/lua]

and

[lua]
if CLIENT then
local function ChangeColour()
for k, v in pairs(player.GetAll()) do
if v:IsTraitor() then
ENT.TargetIDHint = {
name = “Test”
};
end
end
end
end
[/lua]

But it doesn’t work… I’m trying to change the name when you aim The Entity…

No no no no…

use v.TargetIDHint

What ?

What entity ?

It’s the weapon.

The file It’s like a Traitor Health station.

What I want to do is:
If Player is Traitor then
Colour of the Health Station is Red (setcolor(255, 0, 0))

How can I do that with lua code is my question

anyone? :confused: