#"attempt to call a table value" error from module script despite returning a boolean?

1 messages · Page 1 of 1 (latest)

agile bridge
#

literally returning a boolean, true or false, no clue whats causing this error.

#

server code

#

module script code

#

tl;dr, its checking if a raycast hit a humanoid

#

and im getting an error in the output saying "attempt to call a table value"

wheat musk
#

show relevant code

agile bridge
#

hit is a little function that just prints "hit"

#

doesnt even need to be a function tbh

wheat musk
#

pal...

wheat musk
agile bridge
#

oh yeah mb

#
function hit()
    print("hit")
end

script.fire.OnServerEvent:Connect(function(plr:Player,pos:CFrame)
    if equipped == true then
        if debounce == false then
            debounce = true
            result = shoot.fire(plr,pos.Position,pos.LookVector,damage,range,nil)
            
            if result ~= nil then
                endPos = result.Position
                local hitcheck = check(result)
                if hitcheck == true then
                    hit()
                end
            else
                endPos = pos.Position+pos.LookVector*range
            end
            
            script.Parent.tommy.fx:FireClient(plr,endPos)
            
            startPos = script.Parent["3psTommy"].tip.CFrame.Position
            
            trace.trace(plr.Name,startPos,endPos,stats.tracerColor,stats.fadeTime)
            
            wait(firerate)
            debounce = false
        else return end
    end
end)
#

didnt think the extra stuff was relevant

#

i get the error at line 40

wheat musk
#

that still doesnt show where you define check

agile bridge
#
local lib = require(game.ReplicatedStorage.weps:WaitForChild("library"))
local shoot = lib.basicHitscan
local trace = lib.basicTracer
local check = lib.basicHitcheck
#

lib is just a module script that requires all the other necessary module scripts

#

(shoot, trace, check)

#

shoot and trace work perfectly fine

wheat musk
#

do you have anything else inside of that module script or just the check functionm

agile bridge
#

just the check function

wheat musk
#

ok you dont need to return a table then

#

just return the function

agile bridge
#

?

#

i understand not

wheat musk
#
local function check(raycast: RaycastResult): boolean
    -- wtv
end

return check
agile bridge
#

still getting the error

#

wait

#

im dumb

#

no code to set the boolean

#

how would i set the boolean?

wheat musk
#

what do you mean 😭

agile bridge
#

the code is taking in a raycastresult, and is trying to spit out a boolean based on whether or not sait raycastresult hit a player

#

how would i tell the code whther or not to spit out true or false

wheat musk
#

what 😭

agile bridge
#

man im just as confused as you what im asking is how would i spit out the boolean if its just returning the function itself

#

HOLLLYYYY HSIT IM STUPID

#

IT WAS CALLING THE MODULE SCRIPT INSTEAD OF THE FUNCTION IN THE MODULE SCRIPT

#

🥀

wheat musk
#

thats why i told you to change it to a function 😭