Physgun

As part of a script, I have set


H, S, L = 0, 190, 50

This set the physgun for everyone to be this. Is there anyway so only one person who is set to get this, only gets it?

Could you be more specific? Are you asking for only one person to get a physgun colour?

There is a script where there is a rainbow physgun. I start by setting the H, S, L. This then makes everyone’s physgun white and a bit brighter.

Could you post the script’s code?



function rainbow()
    for k, v in pairs(player.GetAll()) do
        function randomize(v)
			HSLtoRGB(H,S,L);
            local col = v:GetInfo( "cl_weaponcolor" )
            v:SetWeaponColor( Vector( col ) )
			v:ConCommand("cl_weaponcolor ".. R .." ".. G .." ".. B)
			H = H+5
			if H > 254 then H=0 end
		end

        if v:GetUserGroup() == "admin" then
		    randomize(v)
        end
	end
end

function HSLtoRGB(H, S, L)
    H, S, L = math.min(240, H), math.min(240, S), math.min(240, L)
    H, S, L = math.max(0, H), math.max(0, S), math.max(0, L)
    R, G, B = 0, 0, 0
    if H < 80 then
        R = math.min(255, 255 * (80 - H) / 40)
    elseif H > 160 then
        R = math.min(255, 255 * (H - 160) / 40)
    end
    if H < 160 then
        G = math.min(255, 255 * (80 - math.abs(H - 80)) / 40)
    end
    if H > 80 then
        B = math.min(255, 255 * (80 - math.abs(H - 160)) / 40)
    end
    if S < 240 then
        k = S / 240
        R, G, B = R*k, G*k, B*k
        k = 128 * (240 - S) / 240
        R, G, B = R+k, G+k, B+k
    end
    k = (120 - math.abs(L - 120)) / 120
    R, G, B = R*k, G*k, B*k
    if L > 120 then
        k = 256 * (L - 120) / 120
        R, G, B = R+k, G+k, B+k
    end
    return R, G, B
end

hook.Add("Initialize", "Initialize.rainbow", timer.Create("wait", .075, 0, rainbow))


1.) Localize those functions.
2.) Where it says


for k, v in pairs (player.GetAll())

Set it to a player you want.

3.) Get rid of the randomize function, just run the code…

Also, timer.Create does not return a function, so that Initialize hook is useless.