I’m trying to make it so that it calculates which face the part is on and sets the character to a 90/180 degree angle so that the character faces it straight.
game:GetService("RunService").RenderStepped:Connect(function()
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Blacklist
Params.FilterDescendantsInstances = {game.Workspace.NoClimb, Character}
local ray = workspace:Raycast(Character.Head.CFrame.Position,Character.Head.CFrame.lookVector*1 ,Params)
if ray and not Holding and ledgeAvailable then
if Character.Head.Position.Y >= (ray.Instance.Position.Y + (ray.Instance.Size.Y / 2)) - 1.5 and Character.Head.Position.Y <= ray.Instance.Position.Y + (ray.Instance.Size.Y / 2) and Character.Humanoid.FloorMaterial == Enum.Material.Air and HumRP.Velocity.Y >= 0 then
Holding = true;
ledgeAvailable = false;
Character.HumanoidRootPart.CFrame = CFrame.new(ray.Position) * CFrame.Angles(math.rad(ray.Normal.X), math.rad(ray.Normal.Y), math.rad(ray.Normal.Z))
Character.HumanoidRootPart.CFrame = CFrame.lookAt(HumRP.Position, Vector3.new(ray.Instance.Position.X, math.floor(HumRP.Position.Y), ray.Instance.Position.Z))
Humanoid.AutoRotate = false
Humanoid:ChangeState(Enum.HumanoidStateType.PlatformStanding)
warn(ray.Position)
warn(ray.Normal)
HumRP.Anchored = true
end
end
end)
I just tried to do this in studio, and really struggled to figure it out for like 15 mins. Normals have never been easy for me to work with. Here’s what I got:
I don’t know why the second surface slants the neon part.
Here’s the command: local params = RaycastParams.new() params.FilterType = Enum.RaycastFilterType.Blacklist params.FilterDescendantsInstances = {workspace.test} local result = workspace:Raycast(workspace.CurrentCamera.CFrame.Position, workspace.CurrentCamera.CFrame.LookVector * 100, params) local atPos = ((result.Instance.CFrame.Rotation + result.Position) * CFrame.new(result.Instance.CFrame:VectorToObjectSpace(result.Normal))).Position workspace.test.CFrame = CFrame.lookAt(atPos, result.Position, result.Instance.CFrame.UpVector)
if you can read any of that, lol. writing in a single line is hard to read.
workspace.test = neon red part workspace.Part = rotated gray part
is supposed to position the character to face the ray so that if for example i went to the side of the box it wouldn’t angle me the wrong way (the issue im having)