I’m currently making an arena with weapons. I want the players to communicate with their team using their radios.
After making the radio. I realized that If you de-activate the radio and activate It again, the message that the player said, will be displayed twice.
I have tried searching on the dev forum for a solution but I couldn’t find anything. I don’t know how to fix this at all.
Here Is my code, sorry If It’s messy
db = true
script.Parent.Equipped:Connect(function()
local startergui = game:GetService("StarterGui"):WaitForChild("RedRadioGUI")
local character = script.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local mygui = player.PlayerGui.RedRadioGUI
for _, players in pairs(game.Players:GetChildren()) do
if players:FindFirstChild("PlayerGui") then
if players.PlayerGui:FindFirstChild("RedRadioGUI") then
local playergui = players.PlayerGui.RedRadioGUI
mygui.Enabled = true
mygui.RadioChat.GUIOpen.Value = true
script.Parent.Activated:Connect(function()
if script.Parent.ActivatedL.Value == false then
script.Parent.ChatOff.Value = false
script.Parent.ActivationLine.BeepOn:Play()
script.Parent.ActivationLine.BrickColor = BrickColor.new("Artichoke")
script.Parent.ActivatedL.Value = true
player.Chatted:Connect(function(message)
if mygui.RadioChat.GUIOpen.Value == true then
if script.Parent.ChatOff.Value == false then
playergui.RadioChat.AtTextValue.Value = playergui.RadioChat.AtTextValue.Value + 1
playergui.RadioChat.Text1.TextName.Text = player.Name
playergui.RadioChat.Text1.Text.Text = message
startergui.RadioChat.AtTextValue.Value = startergui.RadioChat.AtTextValue.Value + 1
startergui.RadioChat.Text1.TextName.Text = player.Name
startergui.RadioChat.Text1.Text.Text = message
end
end
end)
elseif script.Parent.ActivatedL.Value == true then
script.Parent.ActivationLine.BeepOff:Play()
script.Parent.ActivationLine.BrickColor = BrickColor.new("Persimmon")
script.Parent.ActivatedL.Value = false
script.Parent.ChatOff.Value = true
end
end)
end
end
end
end)
This Is the radio and It’s children.
Here Is the radio GUI, located In StarterGui
I’m trying to provide as much Info as possible, If you would like some more Info, just shoot a comment.
Thank you.