How do I kick player when clicked notification button

Hi, I made a notification that when a player joins, a warning will pop up. If the user clicks the Agree button, the notification would dismiss. But what I need help with, how do I kick the player with a message if they click the Decline button?
This is what the notification looks like:
image

The script:
local function callback(Text)
if Text == “Agree” then
print (“Answer”)
elseif Text == (“Decline”) then
–action to kick should be here
end
end

local NotificationBindable = Instance.new("BindableFunction")
NotificationBindable.OnInvoke = callback
--
game.StarterGui:SetCore("SendNotification",  {
	Title = "WARNING";
	Text = "This game contains flashing lights and loud audios. Not suitable for anyone with photosensitive epilepsy.";
	Icon = "rbxassetid://240664703";
	Duration = 100;
	Button1 = "Agree";
	Button2 = "Decline";
	Callback = NotificationBindable;
})

well given this is in a local script, you can only the client, so

elseif Text == (“Decline”) then
game:GetService("Players").LocalPlayer:Kick("Have a great day")
end

also for your problem with formatting use ‘’’ on each side while formatting

2 Likes

Thank you so much, it worked!!