Answered by
5 years ago Edited 5 years ago
Make a ServerScript
in ServerScriptService
and put this code in (change values as nessacary shown in the comments!)
01 | local ChatService = require(game:GetService( "ServerScriptService" ):WaitForChild( "ChatServiceRunner" ):WaitForChild( "ChatService" )) |
04 | game.Players.PlayerAdded:Connect( function (player) |
05 | while not ChatService:GetSpeaker(player.Name) do wait() end |
06 | local speaker = ChatService:GetSpeaker(player.Name) |
07 | if player:GetRoleInGroup(groupId) = = "Guest" then return end |
08 | speaker:SetExtraData( "Tags" , { { TagText = player:GetRoleInGroup(groupId), TagColor = Color 3. fromRGB( 0 , 255 , 0 ) } } ) |
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!)
01 | local sendPopup = game.ReplicatedStorage.SendWhisperChatPopup |
02 | local TextService = game:GetService( "TextService" ) |
04 | local function Run(ChatService) |
05 | local function filterMessage(message, speaker, reciever) |
06 | local filteringResult = TextService:FilterStringAsync(message, speaker.UserId) |
07 | if not game.Chat:CanUserChatAsync(speaker.UserId) or not game.Chat:CanUserChatAsync(reciever.UserId) or not game.Chat:CanUsersChatAsync(speaker.UserId, reciever.UserId) then |
11 | return filteringResult:GetChatForUserAsync(reciever.UserId) |
14 | local function whisperCheck(speakerName, message, channelName) |
15 | if string.sub(channelName, 1 , 2 ) = = "To" then |
16 | local otherPlayer = game.Players:FindFirstChild(string.sub(channelName, 4 )) |
17 | local speakerPlayer = game.Players:FindFirstChild(speakerName) |
19 | local succ, err = pcall ( function () newMessage = filterMessage(message, speakerPlayer, otherPlayer) end ) |
20 | if newMessage = = 0 then |
22 | sendPopup:FireClient(speakerPlayer, "Note" , "One of you can't chat!" ) |
26 | sendPopup:FireClient(speakerPlayer, "Filtering failure" , err) |
30 | sendPopup:FireClient(otherPlayer, speakerName, newMessage) |
36 | ChatService:RegisterProcessCommandsFunction( "whisperCheck" , whisperCheck) |
- Next, make a
ScreenGui
in StarterGui
- Insert a
LocalScript
into the ScreenGui
and put this in it (remember to reference the remote event you made earlier where you need to!)
01 | local inSession = false |
02 | local START_POS = UDim 2. new( 0 , - 300 , 1 , 0 ) |
03 | local END_POS = UDim 2. new( 0 , 0 , 1 , 0 ) |
04 | local SIZE = UDim 2. new( 0 , 200 , 0 , 50 ) |
05 | local ANCHOR_POINT = Vector 2. new( 0 , 1 ) |
07 | local doneEvent = Instance.new( "BindableEvent" , script.Parent) |
09 | local function showLabel(speakerName, message) |
12 | local label = Instance.new( "TextLabel" , script.Parent) |
13 | label.Name = "WhisperBox" |
14 | label.BackgroundColor 3 = Color 3. fromRGB( 0 , 0 , 0 ) |
15 | label.BackgroundTransparency = 0.5 |
16 | label.BorderSizePixel = 0 |
17 | label.Font = Enum.Font.SciFi |
18 | label.TextScaled = true |
19 | label.TextColor 3 = Color 3. fromRGB( 255 , 255 , 255 ) |
20 | label.AnchorPoint = ANCHOR_POINT |
21 | label.Position = START_POS |
23 | label.Text = speakerName.. ": " ..message |
24 | label:TweenPosition(END_POS, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, TIME, true ) |
26 | label:TweenPosition(START_POS, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, TIME, true ) |
33 | doneEvent.Event:Wait() |
34 | showLabel(speakerName, message) |
38 | game.ReplicatedStorage.SendWhisperChatPopup.OnClientEvent:Connect(showLabel) |
I tested it and it works!