I’m currently making a radio system for an SCPF. It has multiple channels. The issue is that players cannot see the first channel unless they switch to another channel and then back to that channel. After that, everything works fine.
I can’t seem to see what’s wrong.
This is the clientside radio script that’s in the gui:
local channel = script.Parent.Channel
require(script.Parent.RadioGlobals).refresh() -- Initial setup on clone or creation.
channel.Changed:Connect(function()
require(script.Parent.RadioGlobals).refresh()
channel.Value.L1.Changed:Connect(function()
print("Channel updated and replicated to client.")
require(script.Parent.RadioGlobals).refresh()
end)
end)
game.Players.LocalPlayer.Chatted:Connect(function(chat)
if(game.Players.LocalPlayer.Character:FindFirstChild("Radio")) then
if(game.Players.LocalPlayer.Character.Radio.On.Value == true) then
channel.Value.chat:FireServer(chat)
end
end
end)
You may see that it require()s the RadioGlobals module, the function in it is here:
function radio.refresh()
for i,v in pairs(script.Parent.Channel.Value:GetChildren()) do
if(v:IsA("StringValue")) then
local name = v.Name
script.Parent.Main.Lines[name].Text = v.Value
end
end
end
And finally, the serverside “logic” controller is here:
local teams = {
game.Teams["Intelligence Agency"],
game.Teams["[<?>]"],
game.Teams["Internal Security Department"],
game.Teams["Rapid Response Team"]
}
function checkteam(teaminstance)
for i,v in pairs(teams) do
if(v == teaminstance) then
return true
end
end
return false
end
script.Parent.chat.OnServerEvent:Connect(function(client,chat)
local success,err = pcall(function()
if(chat ~= script.Parent.L1.Value) then
script.Parent.L6.Value = script.Parent.L5.Value
script.Parent.L5.Value = script.Parent.L4.Value
script.Parent.L4.Value = script.Parent.L3.Value
script.Parent.L3.Value = script.Parent.L2.Value
script.Parent.L2.Value = script.Parent.L1.Value
if(checkteam(client.Team)) then
script.Parent.L1.Value = "[REDACTED]: "..game:GetService("Chat"):FilterStringAsync(string.gsub(chat,"/e",""),client,client)
else
script.Parent.L1.Value = client.Name..": "..game:GetService("Chat"):FilterStringAsync(string.gsub(chat,"/e",""),client,client)
end
end
end)
if(not success) then
script.Parent.L1.Value = "ERROR: "..err
end
end)
If anybody could help me with this, that’d be awesome!
Also, any improvements on the scripts would be widely appreciated! I feel like I should do some things different ways.