New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

Anyone know anything about the ChatSystem? I don't understand it at all..

Asked by 11 days ago
Edited 11 days ago

I was at this game called Ragdoll System Test (https://www.roblox.com/games/1401417393/Ragdoll-System-Test) THIS IS JUST FOUR QUESTIONS I'M ASKING FOR ANY SCRIPTERS WHO KNOW ABOUT THE CHATSYSTEM AND HOW IT WORKS I saw that if you whisper someone, there is a special box that pops up instead of it being in the general chat. I have two questions.. One) Is this a custom chatsystem & Two) How would this be done? The next question is about chat tags.. is it possible to have it where chat tags can show your group rank? I'm asking because I don't want to put all the time and effort in to do all of this and then I end up finding out that it's not able to be done. Here's the script. game>StarterGui>ChatFont

local ChatSettings = require(game.Chat:WaitForChild('ClientChatModules').ChatSettings)

ChatSettings.WindowResizable = true;
ChatSettings.DefaultFont = Enum.Font.SciFi;
ChatSettings.ChatBarFont = Enum.Font.SciFi;

0
Honestly, even if I could make it where it gave people a tag stating they were in the group would be nice. MillerrIAm 209 — 11d
0
im trying to see, wait throwawayaccount2001 61 — 11d
0
alright MillerrIAm 209 — 11d
View all comments (7 more)
0
Nearly forgot, its in a local script. MillerrIAm 209 — 11d
0
im trying to figure out a solution, but studio isn't loading my places so i cant do anything throwawayaccount2001 61 — 11d
0
Do you have a discord? If so, add me MillerrIAm#9898 MillerrIAm 209 — 11d
0
i think roblox isn't working right, there is a bar saying so at the top of the home page, i got it to sorta work but it keeps showing [???] throwawayaccount2001 61 — 11d
0
game.Players.PlayerAdded calls are not working i think roblox is actually broken todya throwawayaccount2001 61 — 11d
0
Oh jesus MillerrIAm 209 — 11d
0
your local script works fine throwawayaccount2001 61 — 11d

1 answer

Log in to vote
0
Answered by 11 days ago
Edited 11 days ago

Make a ServerScript in ServerScriptService and put this code in (change values as nessacary shown in the comments!)

local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local groupId = 000000 -- Group ID here

game.Players.PlayerAdded:Connect(function(player)
    while not ChatService:GetSpeaker(player.Name) do wait() end -- Wait till the player's speaker (thing that allows it to chat) exists
    local speaker = ChatService:GetSpeaker(player.Name)
    if player:GetRoleInGroup(groupId) == "Guest" then return end -- Remove this if you want it to do say [Guest] if they player isn't in the group
    speaker:SetExtraData("Tags", {{TagText = player:GetRoleInGroup(groupId), TagColor = Color3.fromRGB(0, 255, 0)}})
    -- Change the values in Color3.fromRGB() for a different tag color
end)

For the whisper chat (do this pre-runtime)(anytime i bold a name you must write it just like that): 1. Insert a Folder into Chat called "ChatModules" 2. Insert a BoolValue into **ChatModules** called "InsertDefaultModules" and set it's value to true 3. Insert a ModuleScript into ChatModules and put this in the module (make sure to make the remote event that the script references!)

local sendPopup = game.ReplicatedStorage.SendWhisperChatPopup -- Reference a remote event
local TextService = game:GetService("TextService") -- Filter messages so they have no swears

local function Run(ChatService)
    local function filterMessage(message, speaker, reciever)
        local filteringResult = TextService:FilterStringAsync(message, speaker.UserId)
        if not game.Chat:CanUserChatAsync(speaker.UserId) or not game.Chat:CanUserChatAsync(reciever.UserId) or not game.Chat:CanUsersChatAsync(speaker.UserId, reciever.UserId) then
            -- Player(s) cannot chat, send back a DONT SEND MESSAGE prompt
            return 0
        end
        return filteringResult:GetChatForUserAsync(reciever.UserId)
    end

    local function whisperCheck(speakerName, message, channelName)
        if string.sub(channelName, 1, 2) == "To" then -- If whisper channel then
            local otherPlayer = game.Players:FindFirstChild(string.sub(channelName, 4)) -- Get the other player
            local speakerPlayer = game.Players:FindFirstChild(speakerName) -- Get the player who said something
            local newMessage
            local succ, err = pcall(function() newMessage = filterMessage(message, speakerPlayer, otherPlayer) end)
            if newMessage == 0 then
                -- Player can't chat
                sendPopup:FireClient(speakerPlayer, "Note", "One of you can't chat!")
                return true
            end
            if err then
                sendPopup:FireClient(speakerPlayer, "Filtering failure", err)
                return true
            end
            -- We can send message
            sendPopup:FireClient(otherPlayer, speakerName, newMessage)
            return true
        end
        return false
    end

    ChatService:RegisterProcessCommandsFunction("whisperCheck", whisperCheck)
end

return Run
  1. Next, make a ScreenGui in StarterGui
  2. Insert a LocalScript into the ScreenGui and put this in it (remember to reference the remote event you made earlier where you need to!)
local inSession = false -- if another chat is on screen
local START_POS = UDim2.new(0, -300, 1, 0)
local END_POS = UDim2.new(0, 0, 1, 0)
local SIZE = UDim2.new(0, 200, 0, 50)
local ANCHOR_POINT = Vector2.new(0,1)
local TIME = 0.2
local doneEvent = Instance.new("BindableEvent", script.Parent)

local function showLabel(speakerName, message)
    if not inSession then
        inSession = true
        local label = Instance.new("TextLabel", script.Parent)
        label.Name = "WhisperBox"
        label.BackgroundColor3 = Color3.fromRGB(0,0,0)
        label.BackgroundTransparency = 0.5
        label.BorderSizePixel = 0
        label.Font = Enum.Font.SciFi
        label.TextScaled = true
        label.TextColor3 = Color3.fromRGB(255,255,255)
        label.AnchorPoint = ANCHOR_POINT
        label.Position = START_POS
        label.Size = SIZE
        label.Text = speakerName..": "..message
        label:TweenPosition(END_POS, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, TIME, true)
        wait(5 + TIME)
        label:TweenPosition(START_POS, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, TIME, true)
        wait(TIME)
        label:Destroy()
        label = nil
        inSession = false
        doneEvent:Fire()
    else
        doneEvent.Event:Wait()
        showLabel(speakerName, message)
    end
end

game.ReplicatedStorage.SendWhisperChatPopup.OnClientEvent:Connect(showLabel)

I tested it and it works!

Ad

Answer this question