Hey, so I am trying to make a radio gui but there's a problem

So I am trying it to update the textbox for everyone in the game with the gui, here is the code and the gif.

script.Parent.Equipped:Connect(function(player)

	 playewr = script.Parent.Parent
	 player = game.Players:FindFirstChild(playewr.Name)
	
	
	player.Chatted:Connect(function(msg, reci)
		print('hi')
		--print(msg, player.Name)
		local sf = player.PlayerGui:WaitForChild("WalkieTalkieGui").ScrollingFrame
		
		for i,v in pairs(game.Players:GetChildren())do
		
			
			local clone = player.PlayerGui:WaitForChild("WalkieTalkieGui").TextButton:Clone()

			text = player.Name..": "..msg
			clone.Text = text
			clone.Visible = true
			clone.Parent = sf
			clone.TextColor = player.TeamColor
				
				
				
			
			
		end


	end)

	script.Parent.Unequipped:Connect(function()
		

	end)
end)

https://gyazo.com/54be302f12555fa89aba0ce02dde0f42

2 Likes

Find a way to disable the script when you unequip it, and then add another script to enable the script again when it’s equipped. There is probably a more efficient way to do this, but I feel like that should solve the problem.

wow ok red, i will try this out thank you very much kind man

tool = script.Parent

tool.Unequipped:Connect(function()
	--stop all actions
end)

You can use the Equipped event which fires whenever a tool is unequipped.