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

My notification that asks a question isn't working proparly how do i fix it?

Asked by
Uluomis 32
5 years ago

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

01local function callback(Text)
02 if Text == "Yes" then
03  print("Yes")
04 elseif Text == "No" then
05  print("No")
06 end
07end
08 
09local NotificationBindable = Instance.new("BindableFunction")
10NotificationBindable .OnInvoke = callback()
11 
12game.StarterGui:SetCore("SendNotification",{
13 Title = "UwU Hello";
14 Text = "Do u like flamingo";
15 Icon = "";
16 Duration = "5";
17 Button1 = "Yes";
18 Button2 = "No";
19 callback0 = NotificationBindable
20})

2 answers

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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

01local NotificationBindable = Instance.new("BindableFunction")
02NotificationBindable.OnInvoke = function(Text)
03    if Text == "Yes" then
04        print("Yes")
05    elseif Text == "No" then
06        print("No")
07    end
08end
09 
10game.StarterGui:SetCore("SendNotification",{
11 Title = "UwU Hello";
12 Text = "Do u like flamingo";
13 Icon = "";
14 Duration = "5";
15 Button1 = "Yes";
16 Button2 = "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

0
thanks ill see if this works Uluomis 32 — 5y
0
im glad you found out about this Uluomis 32 — 5y
0
works thank you so much i was about to give up on this script i really apreciate it Uluomis 32 — 5y
0
np :p DanzLua 2879 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

My Code:

01-- Local Script in StarterGui
02function btnClick(btn)
03    if btn == 'Yes' then
04        print('Yes')
05    elseif btn == 'No' then
06        print('No')
07    end
08end
09notifyBindable = Instance.new('BindableFunction')
10notifyBindable.OnInvoke = btnClick
11game.StarterGui:SetCore('SendNotification', {
12    Title = 'Question';
13    Text = 'This is a question. Please answer it.';
14    Button1 = 'Yes';
15    Button2 = 'No';
16    Duration = 5;
17    Callback = notifyBindable;
18})

Answer this question