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

How do I use the FilterChatAsync? It confuses me as i'm using Fire ALL clients not just one.

Asked by
Galicate 106
5 years ago
Edited by SerpentineKing 5 years ago

I'm using a custom radio script I made, the only problem, is that players can curse with it etc. How can I fix this because I don't 100% understand how to do this or where to start. It fires ALL clients instead of just one. Also I legit cannot use this new form, I can't copy and paste my code into the code blocks...So I cant put it in a code block.

Local Script:

local Active = false
local Player = game.Players.LocalPlayer
local Debounce = false
local RandomNumber

script.Parent.Equipped:Connect(function()
    Active = true
end)

script.Parent.Unequipped:Connect(function()
    Active = false
end)

Player.Chatted:Connect(function(Message)
    if Active == true and Debounce == false and script.Parent.Broken.Value ~= true then
        Debounce = true
        game:GetService("ReplicatedStorage").SendRadioMessage:FireServer(Message)
        wait(1)
        RandomNumber = math.random(1,100)
        if RandomNumber == 50 then
            script.Parent.Broken.Value = true
        end
        Debounce = false
    end
end) 

game:GetService("ReplicatedStorage").RecieveRadioMessage.OnClientEvent:Connect(function(Player, Message)
    if script.Parent.Broken.Value ~= true then
        script.Parent.Handle.Alert:Play()
        game.StarterGui:SetCore("SendNotification", {
            Title = "[RADIO]" .. Player.Name; -- Required. Has to be a string!
            Text = Message; -- Required. Has to be a string!
            Icon = ""; -- Optional, defaults to "" (no icon)
            Duration = 7.5; -- Optional, defaults to 5 seconds
        })
    end
end)
wait(1)

script.Parent.Broken.Changed:Connect(function()
    if script.Parent.Broken.Value == true then
        script.Parent.Handle.ParticleEmitter.Enabled = true
    elseif script.Parent.Broken.Value == false then
        script.Parent.Handle.ParticleEmitter.Enabled = false
    end
end)

Server Script:

game:GetService("ReplicatedStorage").SendRadioMessage.OnServerEvent:Connect(function(Player, Message)
    local FilteredMessage = game.TextService:FilterStringAsync(Message, Player)
    game:GetService("ReplicatedStorage").RecieveRadioMessage:FireAllClients(Player, FilteredMessage)
end)

[SerpentineKing]: Input Correct Code Format

Answer this question