SendNotification not sending notifications

Hello. I am trying to make a script that sends a notification to everyone but I am having a problem. The notification does not send. Here is my code
Server Script:

local HRs = {
	[351821368] = true;
	[246110211] = true;
	[632067688] = true;
}

game.Players.PlayerAdded:Connect(function(player)
	for id,value in ipairs(HRs) do
		if player.UserId == id and HRs[id] == true then
			wait(5)
			game.StarterGui:SetCore("SendNotification", {
				Title = "High Rank Joined";
				Text = player.Name.." has joined!";
				Duration = 7.5;
			})
		end
	end
end)

Either it doesn’t show for the player that joined or it doesn’t work.

I believe SetCore has to be done on the client only, it’s not possible to do it on the server

I made it into a localscript and it’s still not showing up

I have tried putting prints in the code to see where it stops. It seems to stop when a player actually joins the game.

local HRs = {
	[351821368] = true;
	[246110211] = true;
	[632067688] = true;
}
print("Active...")

game.Players.PlayerAdded:Connect(function(player)
	print("Player has joined")
	wait(10)
	for id,value in ipairs(HRs) do
		print("Looping through the HRs table")
		if player.UserId == id and value ~= false then
			print("HR Joined!")
			game.StarterGui:SetCore("SendNotification", {
				Title = "High Rank Joined";
				Text = player.Name.." has joined!";
				Duration = 7.5;
			})
			print(player.Name..' '..id..' '..value)
		end
	end
end)

And in my output, it only prints Active...

The PlayerAdded event only fires on the server side.

Make a script on the server side that sends the name of the player using Remote Events.
Then, make a script on the client side that receives the fired event.

It is very simple.

1 Like

I was already making the code for this! I am gonna use :FireAllClients()

Here is my new code. I’ve decided to check if the player is in a group instead.
Server Script

game.Players.PlayerAdded:Connect(function(player)
	wait(5)
	if player:GetRankInGroup(9017622) >= 253 then
		game.ReplicatedStorage.OnHRJoin:FireAllClients(player.Name)
	end
end)

Local script

game.ReplicatedStorage.OnHRJoin.OnClientEvent:Connect(function(HRName)
	print("Local script caught the event")
	game.StarterGui:SetCore("SendNotification", {
		Title = "HR Joined";
		Text = HRName.." has joined the game!";
		Duration = 7.5;
	})
	print("Send notification successful")
end)

Alright, great.

If the server script in in ServerScriptService, and the local script in in StarterGui, it should function properly. If you have any other issues, let me know.