Hi, I am trying to get the Darkrp Arrest baton to change colors upon using. I have tried many ways to attempt at doing this. If anyone could help me that would be great. It has a material so conventional setcolor or setweaponcolor doesn’t work. This was my attempt at fixing it:
function SWEP:Initialize(wasInitialized)
if (wasInitialized ~= true) then
self:SetHoldType("normal")
self.stickRange = 90
if SERVER then return end
stunstickMaterials = stunstickMaterials or {}
local materialName = "darkrp/" .. self:GetClass()
if stunstickMaterials[materialName] then return end
CreateMaterial(materialName, "VertexLitGeneric", {
["$basetexture"] = "models/debug/debugwhite",
["$surfaceprop"] = "metal",
["$envmap"] = "env_cubemap",
["$envmaptint"] = "[ .5 .5 .5 ]",
["$selfillum"] = 0,
["$model"] = 1
}):SetVector("$color2", self.StickColor:ToVector())
else
if SERVER then return end
stunstickMaterials = stunstickMaterials or {}
local materialName = "darkrp/" .. self:GetClass()
if stunstickMaterials[materialName2] then return end
CreateMaterial(materialName2, "VertexLitGeneric", {
["$basetexture"] = "models/debug/debugwhite",
["$surfaceprop"] = "metal",
["$envmap"] = "env_cubemap",
["$envmaptint"] = "[ .5 .5 .5 ]",
["$selfillum"] = 0,
["$model"] = 1
}):SetVector("$color2", Color(127,127,127,127):ToVector())
stunstickMaterials[materialName2] = true
self.wasInitialized = true
end
end
// it is called with BaseClass.Initialize(true)
and this is the error:
[ERROR] gamemodes/darkrp/entities/weapons/stick_base/shared.lua:40: attempt to index local 'self' (a boolean value) 1. Initialize - gamemodes/darkrp/entities/weapons/stick_base/shared.lua:40 2. unknown - gamemodes/darkrp/entities/weapons/arrest_stick/shared.lua:94