Script doesn't works

Script doesn’t works. No errors appear.

LocalScript:

local radioEvent = game.ReplicatedStorage.RadioChatted

local Event = game.ReplicatedStorage.FilterTextRadio

local Player = game.Players.LocalPlayer

local Team = game:GetService("Teams")["Humans"]

local Name = Player.Name

local Display = ""

Player.Chatted:Connect(function(message)

if Player.Team == Team and message ~= "" then

Event:FireServer(message)

end

end)

local function onClientReceive(message)

Display = message

game.ReplicatedStorage.RadioChatted:FireServer(Player, Name, Display)

end

Event.OnClientEvent:Connect(onClientReceive)

Script in radio:

local radio = script.Parent.Handle
game.ReplicatedStorage.RadioChatted.OnServerEvent:Connect(function(Player, Name, Display)

game:GetService("Chat"):Chat(radio,"[".. Name .."]: ".. Display, Enum.ChatColor.White)

end)

Script in ServerScriptService:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextService = game:GetService("TextService")

local Event = ReplicatedStorage:WaitForChild("FilterTextRadio")

local function filterMessage(msg, fromUser)
local result
local success, err = pcall(function()
	result = TextService:FilterStringAsync(msg, fromUser)
end)
if success then
	return result
end
return false
end

local function getFilteredMessage(text, recipient)
local result
local success, err = pcall(function()
	result = text:GetChatForUserAsync(recipient)
end)
if success then
	return result
end
return false
end

local function onSendMessage(sender, message)
if message ~= "" then
	local filteredMessage = filterMessage(message, sender.UserId)

	if filteredMessage then
		for _, player in pairs(game.Players:GetPlayers()) do
			local filteredMessage = getFilteredMessage(filteredMessage, player.UserId)
			Event:FireClient(player, filteredMessage)
		end
	end
end
end

Event.OnServerEvent:Connect(onSendMessage)

What exactly is this meant to do? And what exactly doesn’t work?

When the players say something in the chat the radio will say what the players said in the chat. No errors appear.

I think the localscript or script in the radio is not working.

What exactly isn’t working though? You need to be specific, we aren’t paid to be here after all. Is there any output? Have you added prints to your script to see where it fails?

I think the problem is you sent the player through the RadioChatted event. When the server receives an event from the client it will instantly put your Player as its first parameter. Try taking Player off and just having it as FireServer(Name, Display). Let me know if it works :slight_smile:

2 Likes