Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this remotefunction function not working?

Asked by 5 years ago
Edited 5 years ago

This is the client script, in a ModuleScript that is required from a localscript:

function inventoryModule:addItem(item, category)

    local canContinue = remotes.InventoryAdd:InvokeServer(item)

    print(canContinue)

    if canContinue == true then

        print("item added")

    elseif canContinue == false then

        print("item not found; exploiter or bad connection")

    end

end

The issue right now is not with the client script. Right now, the server-side function is not running at all:

remotes.InventoryAdd.OnServerInvoke = function(p, item)

    print(p.Name)

    if item then

        return true

    else

        return false

    end

end

Nothing prints. I can change it to print anything, even random strings, and nothing. The server script is running, because if I do this:

local function addInventoryItem(p, item)

    print(p.Name)

        if item then

            return true

        else

            return false

        end

    end



remotes.InventoryAdd.OnServerInvoke = addInventoryItem()

It works. A little bit. The arguments are not passed to the function, so I can an error for p.Name. If I delete the parentheses after remotes.InventoryAdd.OnServerInvoke = addInventoryItem(), which is what it's supposed to be, I get the same problem as before. In short, the server-side function is not running for some reason.

0
Where is the remote function located? ForeverBrown 356 — 5y
0
replicatedstorage, but thats not important because 1) there are no errors in server script and 2) the server script does indeed run on OnServerInvoke if i incorrectly put the parentheses after addInventoryItem. vastqud12 20 — 5y

Answer this question