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


local runs = game:GetService("RunService")
local plrs = game:GetService("Players")

local ballr = 2
local fric = 3

local plr = plrs.LocalPlayer
local isslide = false
local slide_vel = Vector3.new()


runs.Heartbeat:Connect(function(dt)
	local mychar = plr.Character
	if mychar then
		local myhum = mychar:FindFirstChild("Humanoid")
		local myhrp = mychar:FindFirstChild("HumanoidRootPart")
		
		if myhum and myhrp then
			local move_dir = myhum.MoveDirection
			local veloc = myhrp.AssemblyLinearVelocity
			local horvel = Vector3.new(veloc.X, 0, veloc.Z)
			
			if move_dir.Magnitude > 0 then
				isslide = false
				slide_vel = horvel
			else
				if myhum.FloorMaterial ~= Enum.Material.Air then
					if not isslide  then
						isslide = true
						slide_vel = horvel
					end
					slide_vel = math.exp(-fric *dt)
					myhrp.AssemblyLinearVelocity = Vector3.new(slide_vel.X,myhrp.AssemblyLinearVelocity.Y,slide_vel.Z)
				else
					isslide = false
				end
			end
		end
	end
	
	for _, othplr in ipairs((plrs:GetPlayers())) do
		local char = othplr.Character
		if char then
			local hum = char:FindFirstChild("Humanoid")
			local hrp = char:FindFirstChild("HumanoidRootPart")
			local motor = hrp and hrp:FindFirstChild("Motor6D")
			
			if hum and hrp and motor then
				local velocity = hrp.AssemblyLinearVelocity
				local hs = Vector3.new(velocity.X, 0, velocity.Z).Magnitude

				local trs = 0

				if hum.FloorMaterial ~= Enum.Material.Air and hs > 0.1 then
					local angle = (hs / ballr) *dt
					angle = -angle
					motor.C0 = motor.C0 * CFrame.Angles(angle, 0, 0)
				end
				
			end
			
		end
    end
end)