for Z,Q in pairs(workspace.Portals:GetChildren())do local A=script.PortalLabel:Clone()A.RankLabel.Text=Q.RequiredRank.Value A.Parent=Q.Portal Q.Portal.Touched:Connect(function(Z)local A=players:GetPlayerFromCharacter(Z.Parent)if A and(A.Stats.Rank.Value>=Q.RequiredRank.Value and not Q:FindFirstChild(A.Name.."\067\111\111\108\100\111\119\110"))then replicatedStorage.ClientRemotes.TeleportToArea:FireClient(A,Q.AreaToTeleportTo.Value.Name)A.Stats.CurrentArea.Value=Q.AreaToTeleportTo.Value A.RespawnLocation=Q.AreaToTeleportTo.Value.Spawn local Z=Instance.new("\077\111\100\101\108")Z.Name=A.Name.."\067\111\111\108\100\111\119\110"Z.Parent=Q;(game:GetService("\068\101\098\114\105\115")):AddItem(Z,3)end end)end
-- Set up portals
for _, portal in pairs(workspace.Portals:GetChildren()) do
	local label = script.PortalLabel:Clone()
	label.RankLabel.Text = portal.RequiredRank.Value
	label.Parent = portal.Portal
	portal.Portal.Touched:Connect(function(part)
		local player = players:GetPlayerFromCharacter(part.Parent)
		if
			player
			and player.Stats.Rank.Value >= portal.RequiredRank.Value
			and not portal:FindFirstChild(player.Name .. "Cooldown")
		then
			replicatedStorage.ClientRemotes.TeleportToArea:FireClient(player, portal.AreaToTeleportTo.Value.Name)
			player.Stats.CurrentArea.Value = portal.AreaToTeleportTo.Value
			player.RespawnLocation = portal.AreaToTeleportTo.Value.Spawn
			local tag = Instance.new("Model")
			tag.Name = player.Name .. "Cooldown"
			tag.Parent = portal
			game:GetService("Debris"):AddItem(tag, 3)
		end
	end)
end
