Ad
Log in to vote
1

Trying to use BindableFunctions to return a dictionary, not working?

Asked by 7 days ago

I'm trying to use a BindableFunction to return a dictionary full of all items, but the script stops running at "script.GetItems.OnInvoke:Connect(function()" and will not return anything.

Attempting to Fire() this BindableFunction will result in the script refusing to run any further.

My code:

local items = {

    [1] = {
        Name = "Copper Shortsword",
        Description = "A rough shortsword made out of copper. Seems rough but fairly lightweight and easy to swing.",
        Icon = "rbxassetid://1589011700",
        Rarity = "Common",
        Stackable = false,
        Armour = nil,
        Weapon = game.ReplicatedStorage.CopperShortsword
    }


}

script.GetItems.OnInvoke:Connect(function()
    return items
end)
0
OnInvoke is a callback. incapaz 517 — 7d

1 answer

Log in to vote
0
Answered by
incapaz 517
7 days ago
function swordStuff()
    -- Put your table here.
end

script.GetItems.OnInvoke = swordStuff
0
Fixes the item dictionary script, but whenever i do "allitems = workspace.ItemLib.GetItems:Fire()" it stops the script I used Fire() in. tyler1261 20 — 7d
0
It's not :Fire(), it's :Invoke() incapaz 517 — 7d
0
Even with :Invoke() it still breaks the script being called from (it's a normal script, not local) tyler1261 20 — 7d
0
How so? What is the error? incapaz 517 — 7d
View all comments (2 more)
0
By the way they're not like RemoteFunctions, where they're defined from the server and invoked from the client and viceversa, you can call it from the client and invoke it there, and also viceversa. incapaz 517 — 7d
0
It's being invoked from from the server, and recieved by the server. To answer your other question, there is no error, code after that just simply doesn't run. (ex. if i do Instance.new("Part",workspace after that the part won't be created.) tyler1261 20 — 7d
Ad

Answer this question



Ad