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
4 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

local function callback(Text)
 if Text == "Yes" then
  print("Yes")
 elseif Text == "No" then
  print("No")
 end
end

local NotificationBindable = Instance.new("BindableFunction")
NotificationBindable .OnInvoke = callback()

game.StarterGui:SetCore("SendNotification",{
 Title = "UwU Hello";
 Text = "Do u like flamingo";
 Icon = "";
 Duration = "5";
 Button1 = "Yes";
 Button2 = "No";
 callback0 = NotificationBindable
})

2 answers

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
4 years ago
Edited 4 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

local NotificationBindable = Instance.new("BindableFunction")
NotificationBindable.OnInvoke = function(Text)
    if Text == "Yes" then
        print("Yes")
    elseif Text == "No" then
        print("No")
    end
end

game.StarterGui:SetCore("SendNotification",{
 Title = "UwU Hello";
 Text = "Do u like flamingo";
 Icon = "";
 Duration = "5";
 Button1 = "Yes";
 Button2 = "No";
 Callback = NotificationBindable
})

(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 — 4y
0
im glad you found out about this Uluomis 32 — 4y
0
works thank you so much i was about to give up on this script i really apreciate it Uluomis 32 — 4y
0
np :p DanzLua 2879 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

My Code:

-- Local Script in StarterGui
function btnClick(btn)
    if btn == 'Yes' then
        print('Yes')
    elseif btn == 'No' then
        print('No')
    end
end
notifyBindable = Instance.new('BindableFunction')
notifyBindable.OnInvoke = btnClick
game.StarterGui:SetCore('SendNotification', {
    Title = 'Question';
    Text = 'This is a question. Please answer it.';
    Button1 = 'Yes';
    Button2 = 'No';
    Duration = 5;
    Callback = notifyBindable;
})

Answer this question