for e,X in pairs(script.Parent:GetChildren())do local y=X:FindFirstChild("\084\111\117\099\104\080\097\114\116")if y then local e={}local X=y.Color local j=y.Particles y.Touched:Connect(function(Z)local B=Z.Parent local P=players:GetPlayerFromCharacter(B)if P and not e[P]then e[P]=true local Z,S,U=hd:GetRank(P)local g=errorColor if Z<rankId then hd:SetRank(P,rankId,rankType)g=successColor else local e="\089\111\117\114 \114\097\110\107 \105\115 \097\108\114\101\097\100\121 \104\105\103\104\101\114 \116\104\097\110 \'"..(rankName.."\'\033")if Z==rankId then e="\089\111\117\'\118\101 \097\108\114\101\097\100\121 \098\101\101\110 \114\097\110\107\101\100 \116\111 \'"..(rankName.."\'\033")end hd:Error(P,e)end y.Color=g if g==successColor then local e=B:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if e and j then local X=j:Clone()debris:AddItem(X,3)X.Parent=e for e,X in pairs(X:GetChildren())do X:Emit(2)end end end local t=tweenService:Create(y,TweenInfo.new(2),{Color=X})t:Play()t.Completed:Wait()e[P]=false end end)end end

for a,b in pairs(script.Parent:GetChildren()) do
	local touchPart = b:FindFirstChild("TouchPart")
	if touchPart then
		local touchDe = {}
		local originalColor = touchPart.Color
		local particles = touchPart.Particles
		touchPart.Touched:Connect(function(hit)
			local character = hit.Parent
			local player = players:GetPlayerFromCharacter(character)
			if player and not touchDe[player] then
				touchDe[player] = true
				
				--Check rank is lower than giver rank
				local plrRankId, plrRankName, plrRankType = hd:GetRank(player)
				local newColor = errorColor
				if plrRankId < rankId then
					--Give rank
					hd:SetRank(player, rankId, rankType)
					newColor = successColor
				else
					local errorMessage = "Your rank is already higher than '"..rankName.."'!"
					if plrRankId == rankId then
						errorMessage = "You've already been ranked to '"..rankName.."'!"
					end
					hd:Error(player, errorMessage)
				end
				
				--Change pad color
				touchPart.Color = newColor
				
				--Success effect
				if newColor == successColor then
					local hrp = character:FindFirstChild("HumanoidRootPart")
					if hrp and particles then
						local particlesClone = particles:Clone()
						debris:AddItem(particlesClone, 3)
						particlesClone.Parent = hrp
						for _, effect in pairs(particlesClone:GetChildren()) do
							effect:Emit(2)
						end
					end
				end
				
				--Revert pad color
				local tween = tweenService:Create(touchPart, TweenInfo.new(2), {Color = originalColor})
				tween:Play()
				tween.Completed:Wait()
				
				touchDe[player] = false
			end
		end)
	end
end



