(SOLVED) Team only click detector

Hi, I’m wanting to make the script / click detector below for an in-game team only, but I’m not sure where to start.

Here’s the script:

Aa = script.Parent.Aa
Ca = script.Parent.Ca
State = 1

function onclick()
	if State == 1 then
		for i,v in pairs(Aa:GetChildren()) do
			v.CanCollide = false
			v.Transparency = 1
		end
		for i,v in pairs(Ca:GetChildren()) do
			v.CanCollide = true
			v.Transparency = 0
		end
		State = 2
		elseif State == 2 then
		for i,v in pairs(Aa:GetChildren()) do
			v.CanCollide = true
			v.Transparency = 0
		end
		for i,v in pairs(Ca:GetChildren()) do
			v.CanCollide = false
			v.Transparency = 1
		end
		State = 1
	end
end

script.Parent.Show1.ClickDetector.MouseClick:Connect(onclick)

This should be under Scripting Support.

You would need to send the click from a Local Script through a RemoteEvent to a Server script.

On the Server, you would check what Team they are on. Then change the Collision/Transparency if they are on the correct Team.

CHECK TEAM:

REMOTE EVENTS:

You can try deleting the detector on the client and creating it on the server.