Загрузка данных


local Players = game:GetService("Players")

-- ================= НАСТРОЙКИ =================
local Settings = {
	Width = 0.7,  -- ширина тела (1 = обычная, меньше = уже)
	Depth = 0.8,  -- толщина тела спереди-назад (1 = обычная)
}
-- =============================================

local function setX(motor, prop, x)
	local cf = motor[prop]
	motor[prop] = CFrame.new(x, cf.Y, cf.Z) * (cf - cf.Position)
end

local function narrowR15(hum)
	local w = hum:WaitForChild("BodyWidthScale", 5)
	local d = hum:WaitForChild("BodyDepthScale", 5)
	if not w or not d then
		warn("[NarrowBody] Не нашёл масштаб тела у R15")
		return
	end
	w.Value = Settings.Width
	d.Value = Settings.Depth
end

local function narrowR6(char)
	local W, D = Settings.Width, Settings.Depth

	local torso = char:WaitForChild("Torso")
	local leftArm = char:WaitForChild("Left Arm")
	local rightArm = char:WaitForChild("Right Arm")
	local leftLeg = char:WaitForChild("Left Leg")
	local rightLeg = char:WaitForChild("Right Leg")

	local rs = torso:WaitForChild("Right Shoulder")
	local ls = torso:WaitForChild("Left Shoulder")
	local rh = torso:WaitForChild("Right Hip")
	local lh = torso:WaitForChild("Left Hip")

	-- те же размеры, что получает R15 при таком масштабе
	local tw = 2 * W   -- торс
	local aw = 1 * W   -- рука
	local lw = 1 * W   -- нога

	torso.Size = Vector3.new(tw, torso.Size.Y, 1 * D)
	leftArm.Size = Vector3.new(aw, leftArm.Size.Y, 1 * D)
	rightArm.Size = Vector3.new(aw, rightArm.Size.Y, 1 * D)
	leftLeg.Size = Vector3.new(lw, leftLeg.Size.Y, 1 * D)
	rightLeg.Size = Vector3.new(lw, rightLeg.Size.Y, 1 * D)

	setX(rs, "C0", tw / 2)
	setX(rs, "C1", -aw / 2)
	setX(ls, "C0", -tw / 2)
	setX(ls, "C1", aw / 2)
	setX(rh, "C0", lw)
	setX(rh, "C1", lw / 2)
	setX(lh, "C0", -lw)
	setX(lh, "C1", -lw / 2)
end

local function onCharacter(char)
	local hum = char:WaitForChild("Humanoid")
	task.wait(0.3)
	print("[NarrowBody] тип аватара:", hum.RigType.Name)
	if hum.RigType == Enum.HumanoidRigType.R15 then
		narrowR15(hum)
	else
		narrowR6(char)
	end
end

local function onPlayer(plr)
	plr.CharacterAdded:Connect(onCharacter)
	if plr.Character then
		task.spawn(onCharacter, plr.Character)
	end
end

Players.PlayerAdded:Connect(onPlayer)
for _, plr in ipairs(Players:GetPlayers()) do
	onPlayer(plr)
end