Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I check which option a player chose when using setcore:sendnotification?


function lol(text)
	print(text)
end

game.StarterGui:SetCore("SendNotification",{
	Title = "hi";
	Time  = 5;
	Text = "hlol";
	Button1 = "yes";
	Button2 = "no";	
	callback = lol();
})

I tried connecting a callback to a function, but it prints nil everytime with no errors. How do I check which option a player clicked?

1 comment

0

When setting a callback, just remember that you need to do = lol, not = lol(). In the first, you are setting the callback to the function. In the second, you are setting the callback to the return value of the function, which, in this case, is nothing.

1 answer

A callback needs to be a BindableFunction, not actually a function, this is a short example:

local BindableFunction = Instance.new("BindableFunction")

function onClicked(option)
if option == "yes" then
-- what to do if the player presses yes
elseif option == "no" then
-- what to do if the player presses no
end
end

BindableFunction.OnInvoke = onClicked -- set our bindable function's oninvoke to our func

game.StarterGui:SetCore("SendNotification",{
    Title = "hi";
    Time  = 5;
    Text = "hlol";
    Button1 = "yes";
    Button2 = "no"; 
    callback = BindableFunction
})

This discussion is preserved as it was. New answers, comments, and votes are closed.