I have this radio/walkie talkie system in my game that I found in the toolbox and while testing I noticed that the bubble chats that appear are unfiltered, even when testing in game and in studio. I would also like to mention that I do not have a lot of scripting knowledge but I’m able to move around and understand most basic scripts to some degree.
Here is an example of the system in action
I’ve looked at other topics similar to my issue and they either aren’t applicable to my situation or I simply don’t comprehend them. I’ve had a look at this guide but with barely any scripting knowledge I can’t figure out how I would apply such services to my script;
LocalScript
local Chat = game:GetService("Chat")
local Players = game:GetService("Players")
local Radio = script.Parent:WaitForChild("Handle")
local Remote = script.Parent.RemoteEvent
Players.LocalPlayer.Chatted:Connect(function(msg)
if Radio:IsDescendantOf(Players.LocalPlayer.Character) then
Remote:FireServer(msg)
end
end)
Script
local MS = game:GetService("MessagingService")
local Players = game:GetService("Players")
local Chat = game:GetService("Chat")
local MSG_TOPIC = "FunMurderRadio"
local Radio = script.Parent:WaitForChild("Handle")
local Remote = script.Parent.RemoteEvent
local Sound = Instance.new("Sound")
Sound.SoundId = "rbxassetid://757303230"
Sound.RollOffMinDistance = 5
Sound.RollOffMaxDistance = 50
Sound.RollOffMode = Enum.RollOffMode.InverseTapered
Sound.PlayOnRemove = true
local SpeakPart = Instance.new("Part",Radio)
SpeakPart.Size = Vector3.new(0,0,0)
SpeakPart.CanCollide = false
SpeakPart.Transparency = 1
local SpeakWeld = Instance.new("WeldConstraint",SpeakPart)
SpeakWeld.Part0 = SpeakWeld.Parent
SpeakWeld.Part1 = Radio
local Root = script.Parent.Parent:FindFirstChild("HumanoidRootPart")
function onMessage(Data)
Chat:Chat(SpeakPart,Data.Data)
end
local MessageConnection = MS:SubscribeAsync(MSG_TOPIC,onMessage)
Remote.OnServerEvent:Connect(function(Player,msg)
MS:PublishAsync(MSG_TOPIC,msg)
end)
Chat.Chatted:Connect(function(Part)
local AudioPart
if Radio:IsDescendantOf(workspace) then
AudioPart = Radio
elseif Root then
AudioPart = Root
end
if Part == SpeakPart then
local Sound = Sound:Clone()
Sound.Parent = AudioPart
Sound:Destroy()
end
end)
script.Parent.Equipped:Connect(function()
SpeakPart.Position = Radio.Position
SpeakPart.Parent = workspace
end)
script.Parent.Unequipped:Connect(function()
if not script.Parent:IsDescendantOf(workspace) then
SpeakPart.Position = SpeakPart.Position - Vector3.new(0,math.huge,0)
SpeakPart.Parent = script.Parent
end
end)
script.Parent.AncestryChanged:Connect(function()
Root = script.Parent.Parent:FindFirstChild("HumanoidRootPart")
end)