I am making a script for a simple radio system within my game. it works useing by sending a message from the microphone by the players speach to a radio speaker where ChatService:Chat is used to display the message.
The problem lies in the radio script not connecting to the remote event when fired
Main script:
local Microphone = require(script.Microphone)
local Radio = require(script.Radio)
for i,v in pairs(workspace:GetChildren()) do
if v.Name == "RadioMicrophone" then
Microphone.RadioMicrophone(v)
end
end
for i,v in pairs(workspace:GetChildren()) do
if v.Name == "Radio" then
Radio.Stereo(v)
end
end
Microphone Moduel Script
local module = {}
local ChatService = game:GetService("Chat")
module.RadioMicrophone = function(part)
local switch = part.Switch.ProximityPrompt
switch.Triggered:Connect(function(Player)
print("switched")
wait()
if switch.ObjectText == "Start" then
part.Light.Material = Enum.Material.Neon
switch.ObjectText = "End"
Player.Chatted:Connect(function(message)
print(Player.Name .. ": " .. message)
game.ReplicatedStorage.Radio.RadioBroadcast:FireAllClients(Player, message)
print("fired")
end)
elseif switch.ObjectText == "End" then
switch.ObjectText = "Start"
part.Light.Material = Enum.Material.SmoothPlastic
end
end)
end
return module
radio script (the broken one)
local module = {}
local ChatService = game:GetService("Chat")
module.Stereo = function(part)
print("waiting")
wait()
game.ReplicatedStorage.Radio.RadioBroadcast.OnServerEvent:Connect(function(player, message)
print("connected")
local formattedMessage = player.Name .. ": " .. message
ChatService:Chat(part.Stereo, formattedMessage, Enum.ChatColor.Red)
end)
end
return module
Scripts are all located under serverscriptservice. I have been attempting to debug this for over an hour 45 now any help would be greatly appriciated