because this did not work and i'm trying to make the character change angle on a slope like a sonic game and it wont work
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 = moveModel:WaitForChild('LowerTorso'):WaitForChild("Root")
local orig = j.C0
function placeAtMouse()
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.HumanoidRootPart.Position;
local ray = Ray.new(
moveModel.HumanoidRootPart.Position,
Vector3.new(-10, -10, -10)
)
local hit, pos, normal = workspace:FindPartOnRay(ray, moveModel)
if hit ~= nil then
local origin = point + Vector3.new(0, 0.1, 0)
local ray = Ray.new(origin, Vector3.new(0, -1, 0))
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.HumanoidRootPart.Orientation;
j.C0 = orig*CFrame.fromAxisAngle(cross.magnitude == 0 and Vector3.new(1) or cross.unit, angle)
end
end
end
-- check every frame
game:GetService("RunService").RenderStepped:connect(function()
placeAtMouse()
end)
