SetCore SendNotification Callback help

Hello there people, I’m fairly new to using notifications, but I looked for 2 hours and there wasn’t anyone who seemed to be having the same issues as me.

This is the notification code I’m using:
This is the code on the client:

game.StarterGui:SetCore("SendNotification",{
		Title = "Top text";
		Text = "Bottom text";
		Duration = 10;
		Callback = game.ReplicatedStorage.BindableFunction; --yes, I'm sure it's a BindableFunction
		Button1 = "Button1";
		Button2 = "Button2"
	})

and this is the code on the server:

game.ReplicatedStorage:WaitForChild("BindableFunction").OnInvoke = function(who,buttonpressed)
	print("invoke received by "..who)
	if buttonpressed ~= nil then
		print(buttonpressed)
	end
end

I also made a button when it’s clicked, it invokes the same BindableFunction, but that seems to be working pretty alright without any errors:

game.ReplicatedStorage.BindableFunction:Invoke("button")
--handled on the client as well as the other script

Could anyone please explain why this happens and what I can do to fix this?

1 Like

BindableFunctions are not for cross-server communication. Bindables are used to “communicate” with different scripts, while Remotes are used to communicate with the server from the client, or the client to the server. You’ll need to fire the remote event in your BindableFunction handler on the client.

2 Likes

As @sixfalls said, this needs to be a RemoteFunction, not a bindable function.

Client:

local bindable = Instance.new("BindableFunction") -- create a local bindable function

bindable.OnInvoke = function()
    game.ReplicatedStorage.RemoteFunction:InvokeServer("button") -- create a remote function for this
end

game.StarterGui:SetCore("SendNotification",{
		Title = "Top text";
		Text = "Bottom text";
		Duration = 10;
		Callback = bindable
		Button1 = "Button1";
		Button2 = "Button2"
})

Server:

game.ReplicatedStorage:WaitForChild("RemoteFunction").OnServerInvoke = function(who, buttonpressed)
	print("invoke received by "..who)
	if buttonpressed ~= nil then
		print(buttonpressed)
	end
end