Radio Script not Working

Hey everyone! Question for you all…

I’ve made a radio script for my game. The part where it gets enabled from the keybind and everything works, but once it gets to the cloning the textbox part, it doesn’t seem to anymore.

Server Script:

local txtsrvc = game:GetService("TextService")

local plr = script.Parent.Parent.Parent.Parent

if plr.TeamColor == BrickColor.new("Really red") or plr.TeamColor == BrickColor.new("Lime green") then
	script.Parent.Visible = true
else
	script.Parent.Visible = false
end

if plr.TeamColor == BrickColor.new("Really red") then
	script.Parent.rank.BackgroundColor3 = Color3.fromRGB(150,0,0)
	script.Parent.rank.Text = "ADMN"
end

wait(2)

local s = script.Parent.beep:Clone()
s.Parent = plr.Character
	
	

function enable()
	if script.Parent.activated.Value == true then
		script.Parent.activated.Value = false
		script.Parent.enabled.BackgroundColor3 = Color3.fromRGB(150,0,0)
		script.Parent.enabled.Text = "MICROPHONE DISABLED"
	else
		script.Parent.activated.Value = true
		script.Parent.enabled.BackgroundColor3 = Color3.fromRGB(0,150,0)
		script.Parent.enabled.Text = "MICROPHONE ENABLED"
		s:Play()
	end
end

function chatted(msg)
	if script.Parent.activated.Value == true then
		local filteredmsg = game:GetService("Chat"):FilterStringForBroadcast(msg, plr)
		local clone = game.StarterGui.AdminMain.radio.ScrollingFrame.CloneMe:Clone()
		clone.Text = filteredmsg
		clone.Visible = true
	end
end

plr.Chatted:Connect(chatted)
script.Parent.changedevent.OnServerEvent:Connect(enable)

image
image

Any help is appreciated. Thanks!

INSTANCE:Clone() returns an identical copy of the instance, however it sets the parent of the clone to nil. This means that you have to set the parent of the clone yourself! I believe this is the reason why your code is not having the desired outcome.

i.e.

local clone = game.StarterGui.AdminMain.radio.ScrollingFrame.CloneMe:Clone()
clone.Text = filteredmsg
clone.Visible = true
clone.Parent = game.Players.LocalPlayer.PlayerGui.AdminMain.radio.ScrollingFrame

I think your code is correct, but it doesn’t seem to clone at all. Take a look below:

The problem is that this is a server script so you cannot use game.Players.LocalPlayer to get the player. Since you already have the player defined just changed what @PoppyandNeivaarecute said to:

local clone = game.StarterGui.AdminMain.radio.ScrollingFrame.CloneMe:Clone()
clone.Text = filteredmsg
clone.Visible = true
clone.Parent = plr.PlayerGui.AdminMain.radio.ScrollingFrame

Alternatively you could avoid moving it and just clone the one that is already inside the players scrolling frame:

local clone = script.Parent.ScrollingFrame.CloneMe:Clone()
clone.Text = filteredmsg
clone.Visible = true
1 Like

You should be looking in PlayerGui, not starterGui (game.Players[playerName].PlayerGui)