Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a notification that tells you if a HR has joined from a group with a SCP Logo Image?

Asked by 5 years ago

So recently, I found myself in the SCP Genre, and I want to ask how Eltorks SCP:F has made it so it gives a server-wide notification if a HR has joined: etc. (RANK) (Name) has joined.

All help is appreciated.

0
PlayerAdded and :IsInGroup() can get you started. See wiki. Make an attempt at code for real help. xPolarium 1388 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You can use the PlayerAdded Event to check that a player has joined the game, then use their role [string] (:GetRoleInGroup()) or rank [0 to 255] (:GetRankInGroup()) to check if a message should be created.

game:GetService("Players").PlayerAdded:Connect(function(player)
    local groupid = 0
    local role = player:GetRoleInGroup(groupid)
    local rank = player:GetRankInGroup(groupid)
end)

You will require a RemoteEvent since the StarterGui:SetCore() can only be processed by the Client

local remote = Instance.new("RemoteEvent")
remote.Name = "HRJoinEvent"
remote.Parent = game:GetService("ReplicatedStorage")

Using FireAllClients() can be used to allow the message to be created for all players in the server.

remote:FireAllClients(player.Name, role)

Once sent to the Client, the :ChatMakeSystemMessage() Core can be used to create an in-game message.

game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {Text = ("["..role.."] "..name.." has joined.")})

Below, I'm going to use the Rank number to determine when the message is sent since it will encompass more roles than choosing each string with or logic operators

Server Script under ServerScriptService

local remote = Instance.new("RemoteEvent")
remote.Name = "HRJoinEvent"
remote.Parent = game:GetService("ReplicatedStorage")

game:GetService("Players").PlayerAdded:Connect(function(player)
    local groupid = 0
    local role = player:GetRoleInGroup(groupid)
    local rank = player:GetRankInGroup(groupid)
    if rank > 200 then
        remote:FireAllClients(player.Name, role)
    end
end)

Local Script under StarterGui

local remote = game:GetService("ReplicatedStorage"):WaitForChild("HRJoinEvent")

remote.OnClientEvent:Connect(function(name, role)
    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {Text = ("["..role.."] "..name.." has joined.")})
end)
Ad

Answer this question