I recently made a slope aligning system for R6 characters and it works, but there's an issue.
When I move up and down the slope, it works fine: gyazo.com/af1edda4a4110dccddbafba600169906 But when I move sideways, it has this weird problem: gyazo.com/921df524f04d4e3efbf53b980a53cce1 Here is my code (LocalScript in StarterCharacterScripts)
wait() local plr = game.Players.LocalPlayer local char = plr.Character local root = char.HumanoidRootPart local ts = game:GetService("TweenService") while game:GetService("RunService").Heartbeat:Wait() do local r = Ray.new(root.Position, Vector3.new(0,-(char.Humanoid.HipHeight + 7),0)) local _,_,n = workspace:FindPartOnRayWithIgnoreList(r,{char;workspace.Rings}) local vector = (root.CFrame - root.CFrame.p):VectorToObjectSpace(n) print(vector.z * 1.25) if vector.z > 0 then ts:Create(root.RootJoint,TweenInfo.new(0.1),{C0 = CFrame.new(0,vector.z * 1.25,0,-1,0,0,0,0,1,0,1,0) * CFrame.Angles(-vector.z,0,-vector.x)}):Play() else ts:Create(root.RootJoint,TweenInfo.new(0.1),{C0 = CFrame.new(0,-vector.z * 1.25,0,-1,0,0,0,0,1,0,1,0) * CFrame.Angles(-vector.z,0,-vector.x)}):Play() end end
I would appreciate if someone could help fix this for me. Thank you!