Bindable function not running

I’m creating a hitbox system and I have a bindable function that returns any characters inside it

when I invoke the function, it doesn’t print anything, return anything nor give an error

test script (caller):

game.Players.PlayerAdded:Once(function(player)
    while task.wait(5) do
        local result = game:GetService("ReplicatedStorage").GetCharactersInHitbox:Invoke(player.Character:FindFirstChild("HitHitbox", true)
        if not result then print("Nope..") else for _, v in result do print(v.Name) end end --no printing..
    end
end)

script (child of bindable function):

script.Parent.OnInvoke = function(hitbox)
    print("RAN") --doesn't even print this
    local params = OverlapParams.new()
    params.FilterType = OverlapParams.new()
    params.FilterDescendantsInstances = hitbox.Parent:GetChildren()
    local parts = workspace:GetPartsInPart(hitbox, params)
    print(#parts) --> doesn't print
    if not parts[1] then return nil end
    local characters = {}
    for _, v in parts do
        if not v.Parent:FindFirstChild("Humanoid") then continue end
        if table.find(characters, v.Parent) then continue end
        table.insert(characters, v.Parent)
    end
    print(#characters) --> doesn't print
    if not characters[1] then return nil end
    return characters
end

Did you make sure that this is working? Try to check if PlayerAdded is running in the first place

1 Like

yes. It runs

I just realised scripts can’t run in ReplicatedStorage, which is where the BindableFunction is placed inside… you’ll have to move it somewhere else

thanks! it works perfectly now. I’m so stupid to forget this lol

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.