I have this entity, and basically I need to set a variable for that entity but I then want to access it both clientside and serverside. I’m using it to display health. I know there is already a health function and all that but I need this to be separate for many reasons.
I’ve tried this but client just returns nil:
hook.Add( "PlayerSpawnedVehicle", "SetCarHealthNub", function( ply, ent ) if ent:IsValid() and ent:IsVehicle() then ent:SetCarHealth( 100 ) end end)
local entMeta = FindMetaTable( "Entity" ) function entMeta:SetCarHealth( number ) self.CarHealth = number end function entMeta:GetCarHealth() return self.CarHealth end
local speed = 0 speed = veh:GetCarHealth() -- Other code but unnecessary to post