Hey, I'm trying to make a script send a notification.
function Notify(title,message,duration) if title and message and duration then game.StarterGui:SetCore('SendNotification', { Title = title; Text = message; Duration = duration }) end end
So that wouldn't work inside a regular script. It has to be fired from a localscript. My case requires me to call it from a script and not a localscript. So far my best aim is to create a localscript with the content to send a notification. Either that or clone a script that already has it. I've tried the clone method that works only in studio but fails inside of the actual game.
You can use RemoteEvent for that, and make LocalScript use SendNotification when that event is fired.
--LocalScript local Event = <Path to RemoteEvent> function Notify(title,message,duration) if title and message and duration then game:GetService("StarterGui"):SetCore('SendNotification', { Title = title; Text = message; Duration = duration }) end end Event.OnClientEvent:Connect(Notify)
I'm guessing you need to send notification to all players, and for that you can use RemoteEvent:FireAllClients(...)
method
--Script local Event = <Path to RemoteEvent> function Notify(title,message,duration) if title and message and duration then Event:FireAllClients(title,message,duration) end end