So I was trying to make a notification that is a question with options to answer with and what's suppose to happen is when you choose something it prints something in the output but it wouldn't work. I was using BindableFunctions and callbacks to do this. Heres the script used.
vvvvvvvvvv
01 | local function callback(Text) |
02 | if Text = = "Yes" then |
03 | print ( "Yes" ) |
04 | elseif Text = = "No" then |
05 | print ( "No" ) |
06 | end |
07 | end |
08 |
09 | local NotificationBindable = Instance.new( "BindableFunction" ) |
10 | NotificationBindable .OnInvoke = callback() |
11 |
12 | game.StarterGui:SetCore( "SendNotification" , { |
13 | Title = "UwU Hello" ; |
14 | Text = "Do u like flamingo" ; |
15 | Icon = "" ; |
16 | Duration = "5" ; |
17 | Button 1 = "Yes" ; |
18 | Button 2 = "No" ; |
19 | callback 0 = NotificationBindable |
20 | } ) |
Two things were wrong
You were setting .OnInvoke to the result of the callback function And two, callback0 is suppose to be Callback in the table
I also combined the OnInvoke with the function
01 | local NotificationBindable = Instance.new( "BindableFunction" ) |
02 | NotificationBindable.OnInvoke = function (Text) |
03 | if Text = = "Yes" then |
04 | print ( "Yes" ) |
05 | elseif Text = = "No" then |
06 | print ( "No" ) |
07 | end |
08 | end |
09 |
10 | game.StarterGui:SetCore( "SendNotification" , { |
11 | Title = "UwU Hello" ; |
12 | Text = "Do u like flamingo" ; |
13 | Icon = "" ; |
14 | Duration = "5" ; |
15 | Button 1 = "Yes" ; |
16 | Button 2 = "No" ; |
17 | Callback = NotificationBindable |
18 | } ) |
(If you were not to combine it you would do NotificationBindable.OnInvoke=callback)
On a side note, I HAD NO IDEA THIS EXISTED, so thanks it's pretty neat :D
My Code:
01 | -- Local Script in StarterGui |
02 | function btnClick(btn) |
03 | if btn = = 'Yes' then |
04 | print ( 'Yes' ) |
05 | elseif btn = = 'No' then |
06 | print ( 'No' ) |
07 | end |
08 | end |
09 | notifyBindable = Instance.new( 'BindableFunction' ) |
10 | notifyBindable.OnInvoke = btnClick |
11 | game.StarterGui:SetCore( 'SendNotification' , { |
12 | Title = 'Question' ; |
13 | Text = 'This is a question. Please answer it.' ; |
14 | Button 1 = 'Yes' ; |
15 | Button 2 = 'No' ; |
16 | Duration = 5 ; |
17 | Callback = notifyBindable; |
18 | } ) |