StarterGui:SetCore("SendNotification") Issues

Howdy folks. I’m a relatively new member here and this will be first my topic, so please excuse me if I get anything on here wrong. Anyways, to the problem:

I am utilizing the StarterGui:SetCore(“SendNotification”) system to create an easy way to notify the game when a group HR enters my game. The problem is, it doesn’t work. I’ve used pcall() functions and there are no errors. It returns a success just fine. I have used the wiki and tried every solution I can think of to this problem, but for some reason, it just doesn’t work. Maybe it’s a Roblox thing, maybe it is my code and I just didn’t see it?

Dev-Wiki Article I’m Using:

https://gyazo.com/57cc199fb974e9c0fe5d34ddf35f1f31

Example of Problem:
https://gyazo.com/d460ae712b3a235209bb668749eea37f
This is the ONLY output in console regarding this issue.

Clientside Code:

local sgui = game:GetService("StarterGui"); -- located elsewhere, but here for example
--[[
    plrname - string value, player name
    grole - string value, group ROLE (not RANK)
    gtitle - string value, title for notification (Ex: "SCPF HR Has Entered")
    gicon - string value, url link to group icon (retrieved from GroupService:GetGroupInfoAsync().EmblemUrl) 
]]
Network:add("adminentered",function(plrname,grole,gtitle,gicon)
    local Success,ErrorMessage = pcall(function()
        sgui:SetCore("SendNotification",{gtitle,plrname.." :: "..grole,gicon,notifDur,onNotifClicked});
    end)
    if Success ~= true then error(ErrorMessage); else print('SCPF HR Has Entered.'); end
end)

The server transfers everything fine. The client receives it all. The pcall returns true (as seen in the output), so I’m lost here.

Thank you to anyone that helps. This issue isn’t extremely critical to me right now as there are more important parts of the game, but your help is appreciated.

Can we see what the server-side script is trying to transfer to the client?

Getting the Image:
https://gyazo.com/e1ee40e6e5ea505770d1d75b524a4add

Function for Admin’s Entering:
https://gyazo.com/b915abd975ea275f6842a6639e43b7c4

Can’t you just have a PlayerAdded function on the client and if they are an admin do the StarterGui:SetCore(“SendNotification”)?

3 Likes

Ok, first you should make your code a bit more spaced so it’s easier to read
For example:

local sgui = game:GetService("StarterGui"); -- located elsewhere, but here for example
--[[
    plrname - string value, player name
    grole - string value, group ROLE (not RANK)
    gtitle - string value, title for notification (Ex: "SCPF HR Has Entered")
    gicon - string value, url link to group icon (retrieved from GroupService:GetGroupInfoAsync().EmblemUrl) 
]]
Network:add("adminentered",function(plrname,grole,gtitle,gicon)
    --Text that we want the player to receive
    local gtext = plrname.." :: "..grole

    local Successfully,ErrorMessage = pcall(function()
        -- Main Notification code
        sgui:SetCore("SendNotification",
          {
           gtitle, --Title of the Notification
            gtext, -- The middle/main text
            gicon, -- Icon of notification
            notifDur, -- How long the notification should last
            onNotifClicked, --What to do when the notification is clicked
          }
        );
    end)
    -- If a error gets caught
    if not Successfully then
      error(ErrorMessage); 
     else 
     -- Tell us in the console that it should of send us the notification
      print('SCPF HR Has Entered.'); 
     end
end)

Also, I’m having trouble with what is this Network:add is. I think it’s best to use a client-side event call for every admin within your group joins the game(you can do this check within the server-side script)

2 Likes

The second piece of code does that. https://gyazo.com/f2bb646896c0d8647f1c6af5f1e54d61

Issue is, the server starts when one player initiates it. So I have to have that check system at the start. It works right now. Like I said, it’s all the client’s side not handling it.

SendNotification requires a dictionary, but you’re sending an array.

You should do something like this instead:

sgui:SetCore("SendNotification", {
Title = gtitle,
Text = plrname.." :: "..grole,
Icon = gicon,
Duration = notifDur,
Callback = onNotifClicked
}
)
6 Likes

Thank you. That fixed it. I thought it was something simple I overlooked.

1 Like

Oh yeah, I completely forgot about that. Sometimes you can enter the parameters wrong and it won’t display an error.

(Replied to wrong person, sorry.)

Also, as a recommendation, if you use this a lot, I suggest adding a function to a ModuleScript so you can simply pass parameters into it.

1 Like
local sgui = game:GetService("StarterGui"); -- located elsewhere, but here for example
--[[
    plrname - string value, player name
    grole - string value, group ROLE (not RANK)
    gtitle - string value, title for notification (Ex: "SCPF HR Has Entered")
    gicon - string value, url link to group icon (retrieved from GroupService:GetGroupInfoAsync().EmblemUrl) 
]]
Network:add("adminentered",function(plrname,grole,gtitle,gicon)
    --Text that we want the player to receive
    local gtext = plrname.." :: "..grole

    local Data =
    {
      Title = gtitle, --Title of the Notification
      Text = gtext, -- The middle/main text
      Icon = gicon, -- Icon of notification
      Duration = notifDur, -- How long the notification should last
      Callback = onNotifClicked, --What to do when the notification is clicked
    }

    local Successfully,ErrorMessage = pcall(function()
        -- Main Notification code
        sgui:SetCore("SendNotification",
          Data
        );
    end)
    -- If a error gets caught
    if not Successfully then
      error(ErrorMessage); 
     else 
     -- Tell us in the console that it should of send us the notification
      print('SCPF HR Has Entered.'); 
     end
end)

So this would be the end code

Of the sorts. I prefer to format mine differently than that. I’ll keep in mind the spacing on here for the future, but when programming, I keep mine compact.

I tend to space my code a lot so I can keep my sanity, but do what works for you. Just know if you ever encounter a bug, spacing out helps a LOT.

I’m happy you’re problem has been fixed!

Thank you. I’ll be sure to post here more often.