To explain what I'm trying to do;
A humanoid for example walks up a ramp. The humanoid acts as if hes still walking on flat ground trying to walk through the ramp instead of walking up the ramp.
I want to prevent this.
local mouse = game.Players.LocalPlayer:GetMouse() local moveModel = game.Players.LocalPlayer.Character; -- don't detect the model we're moving mouse.TargetFilter = moveModel local c = moveModel; local hrp = c:WaitForChild("HumanoidRootPart") local j = hrp:WaitForChild("Root Hip") local orig = j.C0 function placeAtMouse() -- make sure the mouse is pointing at something if mouse.Target then -- where we cast our ray from (shifted slightly up so the ray will hit the surface we're hovering) local point = moveModel.Torso.Position; local ray = Ray.new( moveModel.Torso.Position, Vector3.new(0, -10, 0) ) local hit, pos, normal = workspace:FindPartOnRay(ray, moveModel) if hit ~= nil then local origin = point + Vector3.new(0, 0.1, 0) -- cast our ray and get our normal, which is a unit vector local ray = Ray.new(origin, Vector3.new(0, -1, 0)) -- get the perpendicular vector and the angle between the two local cross = Vector3.new(0, 1, 0):Cross(normal) local angle = math.asin(cross.magnitude) -- division by 1 is redundant local dude = script:WaitForChild("AngleValue") dude.Value = angle print(angle) local savedCFrame = moveModel.Torso.Orientation; j.C0 = orig*CFrame.fromAxisAngle(cross.magnitude == 0 and Vector3.new(1) or cross.unit, angle) --moveModel.Torso.CFrame = --(CFrame.new(moveModel.Torso.Position)) -- position --* CFrame.fromAxisAngle(cross.magnitude == 0 and Vector3.new(1) or cross.unit, angle) -- angle, cross must not be Vector3.new() local newCFrame; end end end -- check every frame game:GetService("RunService").RenderStepped:connect(function() placeAtMouse() end)
OHHHHH DERP. In humanoid properties. Change the max slope angle to what ever you want! (Make it higher)