for Y,k in pairs(workspace.Portals:GetChildren())do local z=script.PortalLabel:Clone()z.RankLabel.Text=k.RequiredRank.Value z.Parent=k.Portal k.Portal.Touched:Connect(function(Y)local z=players:GetPlayerFromCharacter(Y.Parent)if z and(z.Stats.Rank.Value>=k.RequiredRank.Value and not k:FindFirstChild(z.Name.."\067\111\111\108\100\111\119\110"))then replicatedStorage.ClientRemotes.TeleportToArea:FireClient(z,k.AreaToTeleportTo.Value.Name)z.Stats.CurrentArea.Value=k.AreaToTeleportTo.Value z.RespawnLocation=k.AreaToTeleportTo.Value.Spawn local Y=Instance.new("\077\111\100\101\108")Y.Name=z.Name.."\067\111\111\108\100\111\119\110"Y.Parent=k;(game:GetService("\068\101\098\114\105\115")):AddItem(Y,3)end end)end

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
