SWEP trouble

Herro. Not sure where I am going wrong.

I have a SWEP and for whatever reason, whenever I do SWEP:Owner on the second line, it gives me this error

(This happens both on client and server)
(The error function is the function right after ply being defined)

If I make SWEP:Owner to self.Owner, it just gives me this error.

(This also happens on client and serverside)




function SWEP:GetCuffSize(boneroo)


	local ply = SWEP:Owner

	local function lookupbone(lubone) -- Gets the bone id
		return ply:LookupBone(lubone)
	end

	local JSHBGroups = ply:GetHitBoxGroupCount() -- The amount of groups of hitboxes in the ent
    local JSHBXS = {} -- My little table to store the hitboxs I need
    JSHBXS.LeftHandHB = {}
    JSHBXS.RightHandHB = {}

    for k=0, JSHBGroups - 1 do -- Loops through all the hitbox groups with i = the hitbox group num
        local HBCount = ply:GetHitBoxCount(k) -- The amount of hitboxes in the hitbox group
        
        for v=0, HBCount do -- Loop through all the hitboxes in the group 'i'
            -- k now = the hitbox group and v = the hitbox in that group
            local mybone = ply:GetHitBoxBone(v,k) -- Gets a bone based on k,v

            if mybone == lookupbone(boneroo)  then -- RBS.LHand is the bone id for Left hand
                JSHBXS.LeftHandHB["Group"] = k
                JSHBXS.LeftHandHB["HB"] = v
            elseif mybone == lookupbone(boneroo) then -- Same thing with right hand
                JSHBXS.RightHandHB["Group"] = k
                JSHBXS.RightHandHB["HB"] = v
            end
        end
    end

    -- Now we should have the hitboxes as needed.
	local function jsvecmath(boney)

		local JLH = JSHBXS.LeftHandHB -- So I don't have to type it all out
		local JRH = JSHBXS.RightHandHB

		local function jsquickr(hand)
			return ply:GetHitBoxBounds(hand["Group"], hand["HB"]) -- returns the vectors of hitbox
		end

	    if boney == "ValveBiped.Bip01_L_Hand" then -- If we're dealing with the left hand
	    	local jvmin, jvmax = jsquickr(JLH) -- HB first, then group
	    	local x1,y1,z1 = jvmin
	    	local x2,y2,z2 = jvmax
	    	local x1 = math.abs(x1 - x2) -- get the distance between the two amirite?
	    	local z1 = math.abs(z1 - z2) -- get the distance between the two amirite?
	    	return Vector(x1,.1,z1)

	    elseif boney == "ValveBiped.Bip01_R_Hand" then -- If we're dealing with the right hand
	    	local jvmin, jvmax = jsquickr(JRH) -- HB first, then group
	    	local x1,y1,z1 = jvmin
	    	local x2,y2,z2 = jvmax
	    	local x1 = math.abs(x1 - x2) -- get the distance between the two amirite?
	    	local z1 = math.abs(z1 - z2) -- get the distance between the two amirite?
	    	return Vector(x1,.1,z1)
	   
	    else
	    	return Vector(.17, .1, .17)
	    end
	end


  return jsvecmath(boneroo) -- Gets the vector
-- Edit x and z

end



It should be ply = self:GetOwner(). Also, the way you’re declaring sub-routines inside of the main routine is actually pretty cute, but it’s going to be way more inefficient than just doing the work straight out since you are now adding an extra function call + having to create the function.

[editline]13th August 2017[/editline]

Also, the second error implies you aren’t calling SWEP:GetCuffSize correctly.

I’m still testing the idea, I optimize it after I get it working. Thanks for the help.

Still having the problem.

This is how I call the function



SWEP:GetCuffSize("ValveBiped.Bip01_R_Hand")


[editline]13th August 2017[/editline]

NVM, Fixed it by doing a self.Owner check.