Someone posted in the Faster Lua VM thread with a similar issue. The engineers reply is here:
In the documentation for SendNotification it says the Callback should be of type BindableFunction. Try creating one, passing it in the arguments, and then setting OnInvoke to your function.
Here, let me reformat this to something that looks a little nicer:
StarterGui = game.StarterGui
info = {
Title = 'This is a test',
Text = 'Hello world!',
Icon = '',
Duration = 5,
Callback = function()
warn'waffles'
end
}
StarterGui:SetCore("SendNotification",info)
No, you’re supposed to pass a BindableFunction. Here’s how I use it in one of my old games:
local restartFunc = Instance.new("BindableFunction")
restartFunc.OnInvoke = function(text)
if text == "RESTART" then
funcs.restartGame()
end
end
-- later:
if err then
print("ERROR LOADING BOARD - ",err)
game:GetService("StarterGui"):SetCore("SendNotification", {
Title = "Error!",
Text = "Error loading your board - please restart your game :(",
Icon = '',
Duration = 3600;
Callback = restartFunc,
Button1 = "RESTART",
})
end
In Lua, values of certain types are defined in a very specific way. For example, "hello" defines a string literal, 0 is a number (just a number, without quotes), {} (curly brackets) is a table, etc. Functions act in the same way; they’re defined using function(args, ...) code end or simply function() end. In Lua, functions are first-class values, meaning they can be passed to other functions or stored as variables!
local x = function() doStuff() end
Lua has syntactic sugar for this:
local function x() doStuff() end
The reason you sometimes see end) rather than end is because you’re passing a function literal to another function, like Connect. Lua requires that you balance out your brackets, so when you define a function as an argument, you need to make sure you have a closing parenthesis.
someRBXScriptSignal:Connect(function() --[[ this is a function ]] end)