Any right way to do my script

local groupsandid = {
	GROUP = 1234567, ID = 255,
}

script.Parent.Triggered:Connect(function(p)
	for i,pads in pairs(script.Parent.Parent.Parent:GetChildren()) do
		if p:GetRankInGroup(groupsandid.GROUP) >= groupsandid.ID then
			if pads.Transparency == 0 and pads.CanCollide == true then
				pads.Transparency = 1
				pads.CanCollide = false
			else
				pads.Transparency = 0
				pads.CanCollide = true
			end
		end
	end
end)

I would check that the player is in the group & rank is above ID before you do the loop, right now you’re making the comparison every iteration. The inner logic may be simplified to:

pads.CanCollide = not pads.CanCollide --not true=false, not false=true
pads.Transparency = pads.Transparency==1 and 0 or 1--if 1, set 0. else, set 1.
1 Like