So I have this issue with an admin command of mine, Oath of Silence command, how it’s suppose to work is everyone in the secGroup can run except for the player’s ranked 220, and everyone in the secGroup and certain ranks in the mainGroup can see it, but I’m running into an issue of when a player is reset or on rejoin they no longer see the redacted message instead they see the normal message.
I assume this happens because I have it in StarterCharacterScript, so the information is reset when they reset/die, and my main menu forces a player to be reset to give them the tools and group based GUI. I did try to add a onCharacterAdded function to this, but it still doesn’t work. I also tried adding it to StarterPlayerScripts and this doesn’t work at all. I also tried to get AI to help, but it couldn’t fix it.
Relevant code in adminHandler(There is some stuff left out cause the admin system work and doesn’t need to be messed with):
local activeOOS = {}
local oosRemote = ReplicatedStorage.MiscEvents.OOSRemote
local GetOOSPlayers = ReplicatedStorage.MiscEvents.GetOOSPlayers
local sendOOSPlayers = ReplicatedStorage.MiscEvents.SendOOSPlayers
elseif command == "oos" then
if not player:IsInGroup(secGroup) then return end
local playerRank = player:GetRankInGroup(secGroup)
local state
if playerRank == 220 then
state = true
else
state = not activeOOS[player.UserId]
end
print("OOS DEBUG (COMMAND): "..player.Name.." triggered :oos. New state will be: "..tostring(state)) --<-- ADD THIS PRINT
activeOOS[player.UserId] = state
oosRemote:FireAllClients(player.UserId, state)
print("OOS DEBUG (COMMAND): Fired remote event to all clients for UserId "..player.UserId) --<-- ADD THIS PRINT
sendWebhook(player.Name, ":" .. command)
end
end
game.Players.PlayerRemoving:Connect(function(plr)
if activeOOS[plr.UserId] then
print("OOS DEBUG (LEAVING): "..plr.Name.." had active OOS. Cleaning up.") --<-- ADD THIS PRINT
activeOOS[plr.UserId] = nil
oosRemote:FireAllClients(plr.UserId, false)
end
end)
local function onPlayerRejoin(player)
if player:IsInGroup(secGroup) and player:GetRankInGroup(secGroup) == 220 then
print("OOS DEBUG (JOIN): "..player.Name.." has Rank 220. Automatically enabling OOS.") --<-- ADD THIS PRINT
activeOOS[player.UserId] = true
oosRemote:FireAllClients(player.UserId, true)
print("OOS DEBUG (JOIN): Fired remote event for "..player.Name.."'s auto-OOS.") --<-- ADD THIS PRINT
end
print("OOS DEBUG (JOIN): Checking existing OOS players to inform "..player.Name) --<-- ADD THIS PRINT
for userId, state in pairs(activeOOS) do
if state then
print("OOS DEBUG (JOIN): Found active OOS for UserId "..tostring(userId)..". Firing event.") --<-- ADD THIS PRINT
oosRemote:FireAllClients(userId, true)
end
end
end
GetOOS.OnServerInvoke = function(player)
print("OOS SERVER: Player "..player.Name.." requested the full OOS list.")
return activeOOS
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
MessageHandler:
local TCS = game:GetService("TextChatService")
local Players = game:GetService("Players")
local rbxGeneralChannel = TCS:WaitForChild("TextChannels"):WaitForChild("RBXGeneral")
local mainGroup = 32663277
local secGroup = 32607348
local localPlr = Players.LocalPlayer
local oosRemote = game:GetService("ReplicatedStorage").MiscEvents:WaitForChild("OOSRemote")
local getOOSPlayers = game:GetService("ReplicatedStorage").MiscEvents:WaitForChild("GetOOSPlayers")
local oosPlayers = {}
local isOOSCheckComplete = false
print("OOS CLIENT: messageHandler.lua started for " .. localPlr.Name) --<-- ADD THIS PRINT
local function onCharacterAdded(char)
print("OOS CLIENT (CHARACTER): Character " .. char.Name .. " added.")
if not isOOSCheckComplete then
local oosList = getOOSPlayers:InvokeServer()
if oosList then
oosPlayers = oosList
print("OOS CLIENT: Received full OOS list.")
isOOSCheckComplete = true
else
print("OOS CLIENT: Failed to get OOS list from server.")
end
end
end
localPlr.CharacterAdded:Connect(onCharacterAdded)
if localPlr.Character then
onCharacterAdded(localPlr.Character)
end
oosRemote.OnClientEvent:Connect(function(sourceUserId, state)
print("OOS CLIENT: Received OOS remote event. UserId: "..tostring(sourceUserId).." | State: "..tostring(state)) --<-- ADD THIS PRINT
if not sourceUserId then return end
if state then
oosPlayers[sourceUserId] = true
else
oosPlayers[sourceUserId] = nil
end
print("OOS CLIENT: Updated local oosPlayers table. User "..tostring(sourceUserId).." is now ".. (oosPlayers[sourceUserId] and "OOS" or "NOT OOS")) --<-- ADD THIS PRINT
end)
Players.PlayerRemoving:Connect(function(player)
print("OOS CLIENT: Player "..player.Name.." left, removing from local oosPlayers table.") --<-- ADD THIS PRINT
oosPlayers[player.UserId] = nil
end)
rbxGeneralChannel.OnIncomingMessage = function(textChatMessage)
local senderSource = textChatMessage.TextSource
if not senderSource then return nil end
local senderId = senderSource.UserId
print("OOS CLIENT (MESSAGE): Intercepting message from senderId: "..tostring(senderId)..". Checking OOS status...") --<-- ADD THIS PRINT
if not oosPlayers[senderId] then
print("OOS CLIENT (MESSAGE): Sender "..tostring(senderId).." is NOT OOS. Allowing message.") --<-- ADD THIS PRINT
return nil
end
print("OOS CLIENT (MESSAGE): Sender "..tostring(senderId).." IS OOS. Proceeding to redact.") --<-- ADD THIS PRINT
local textChatMsgProperties = Instance.new("TextChatMessageProperties")
local senderPlayer = Players:GetPlayerByUserId(senderId)
if senderPlayer and senderPlayer:IsInGroup(secGroup) then
if localPlr:IsInGroup(secGroup) then
return nil
elseif localPlr:IsInGroup(mainGroup) and localPlr:GetRankInGroup(mainGroup) == 255 then
return nil
else
if senderPlayer:GetRankInGroup(secGroup) == 220 then
textChatMsgProperties.Text = "[REDACTED] - Oath of Silence"
else
textChatMsgProperties.Text = "[REDACTED] - On Guard Duty"
end
return textChatMsgProperties
end
end
return nil
end