The error I get is [ERROR] addons/armory station pack/lua/weapons/money_test.lua:31: attempt to call field 'Create' (a nil value) 1. unknown - addons/armory station pack/lua/weapons/money_test.lua:31
My gun code is here.
SWEP.PrintName = "Money Test"
SWEP.Author = "( Justin Yates )"
SWEP.Instructions = "Left click to make it rain."
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.Weight = 2
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Slot = 1
SWEP.SlotPos = 2
SWEP.DrawAmmo = true
SWEP.DrawCrosshair = true
SWEP.ViewModel = "models/weapons/v_pistol.mdl"
SWEP.WorldModel = "models/weapons/v_hands.mdl"
function SWEP:PrimaryAttack()
local money = ents.Create("spawned_money")
money:SetPos(self:GetPos())
money.dt.amount = 500
money:Spawn()
money:Activate()
end
It does work but spams the console with lua errors.
If I understand your description right. You're getting this error clientside.
ents.Create()
is a serverside function. To create a clientside entity, you'll need ents.CreateClientProp()
.
Read up on my GMod (It's been a while, since I programmed GMod Lua..) Try this:
function SWEP:PrimaryAttack()
if SERVER then
local money = ents.Create("spawned_money")
money:SetPos(self:GetPos())
money.dt.amount = 500
money:Spawn()
money:Activate()
end
end