Custom Physgun colors for certain ulx ranks.

Hello, I started a server with my friend. We wanted to have Custom Physgun colors for certain ranks.
We are using ULX. I already got this. But it doesn’t work i putted the script in “garrysmod\addons\darkrpmodification-master\lua\darkrp_modules”.


-- sv_rankphysguncolours.lua
local ranks = {}
local function AddExtraRank(id,col)
	ranks[id] = {}
	ranks[id].Color = col
end
	
AddExtraRank("Owner",Color(255,0,0))
AddExtraRank("Head Adminstrator",Color(180,0,225))
AddExtraRank("Senior Adminstrator",Color(255,160,0))
AddExtraRank("Adminstrator",Color(0,255,0))
AddExtraRank("Moderator",Color(0,0,255))
AddExtraRank("Enforcer",Color(0,255,125))
AddExtraRank("User",Color(0,0,0))

local function GetRankPhysgunColor(ply)
	if ucl then
		if ranks[ply:GetUserGroup()] then
			return ranks[ply:GetUserGroup()].Color
		else
			return Color(255,255,255)
		end
	else
		if ply:IsSuperAdmin() then
			return ranks["Owner"].Color(255,0,0)
		elseif ply:IsAdmin() then
			return ranks["Head Adminstrator"].Color(180,0,255)
		else
		    return ranks["Senior Adminstrator"].Color(255,160,0)	\	
		else
		    return ranks["Adminstrator"].Color(0,255,0)
		else 
		    return ranks["Moderator"].Color(0,0,255)
		else
		    return ranks["Enforcer"].Color(0,255,125)
		else
	        return ranks["User"].Color(0,0,0)
		end
	end
end

hook.Add( "PlayerSpawn", "AdminPhysgunCol", function( ply )
	local color = GetRankPhysgunColor(ply)
	timer.Create("setphysguncolour",0.1,1,function()
	ply:SetWeaponColor(Vector(color.r / 255, color.g / 255, color.b / 255))
	end)
end)

hook.Add( "PlayerInitialSpawn", "AdminPhysgunCol2", function( ply )
	local color = GetRankPhysgunColor(ply)
	timer.Create("setinitialphysguncolour",0.1,1,function()
	ply:SetWeaponColor(Vector(color.r / 255, color.g / 255, color.b / 255))
	end)
end)

When i restarted the server and tested it, it didn’t work. Does somebody know how to fix this? I don’t get a error something like that. I think i made a mistake in the script. Can somebody check that? I am not the best at LUA.

Could you be more descriptive please, any errors? Does the script do anything at all? Just posting a giant mess of code isn’t going to get your problem solved. We need to know what we are looking for.

this is the part that’s causing you problems:

[lua]
if ply:IsSuperAdmin() then
return ranks[“Owner”].Color(255,0,0)
elseif ply:IsAdmin() then
return ranks[“Head Adminstrator”].Color(180,0,255)
else
return ranks[“Senior Adminstrator”].Color(255,160,0) \
else
return ranks[“Adminstrator”].Color(0,255,0)
else
return ranks[“Moderator”].Color(0,0,255)
else
return ranks[“Enforcer”].Color(0,255,125)
else
return ranks[“User”].Color(0,0,0)
end
[/lua]

you have bad syntax when it comes to the if statements, you’re only supposed to have one else statement per if statement (use elseif if you need more).

[lua]
if ply:IsSuperAdmin() then
return ranks[“Owner”].Color(255,0,0)
elseif ply:IsAdmin() then
return ranks[“Head Adminstrator”].Color(180,0,255)
–[[else
return ranks[“Senior Adminstrator”].Color(255,160,0)
else
return ranks[“Adminstrator”].Color(0,255,0)
else
return ranks[“Moderator”].Color(0,0,255)
else
return ranks[“Enforcer”].Color(0,255,125)–]]
else
return ranks[“User”].Color(0,0,0)
end
[/lua]

Also it’s probably best if you stick to one method for indentation (either tabs or spaces, mixing them can be a nuisance)

Also, the membe Color is a value, not a function, why are you calling them?