Okay so I have a script that works to walk on walls for small angles, but once the wall is at a more drastic angle the player begins to walk on their own torso or humanoid root part, i'm not sure which.
Can anyone fix this?
Here's the code:
local player = game.Players.LocalPlayer;
local character = player.CharacterAdded:wait();
local torso = character:WaitForChild("Torso");
local hrp = character:WaitForChild("HumanoidRootPart");
local hum = character:WaitForChild("Humanoid");
local root = hrp:WaitForChild("RootJoint");
local rootC0 = root.C0;
local rootC1 = root.C1;
function update()
local ray = Ray.new(hrp.CFrame.p, torso.CFrame:vectorToWorldSpace(Vector3.new(0, -5, 0)));
local hit, pos, normal = game.Workspace:FindPartOnRay(ray, character);
if hit then
local cross = Vector3.new(0, 1, 0):Cross(normal);
cross = cross.magnitude == 0 and Vector3.new(1) or cross;
local angle = math.acos(normal:Dot(Vector3.new(0, 1, 0)));
local lateral = hrp.CFrame - hrp.CFrame.p;
local cf = CFrame.new(pos + normal * 3) * CFrame.fromAxisAngle(cross, angle) * lateral;
root.C0 = hrp.CFrame:inverse() * (cf * rootC1);
else
root.C0 = rootC0;
end;
end;
game:GetService("RunService").RenderStepped:connect(update);

1 comment
I can't answer for another minute or so, quick answer is that you just need to use game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList) and define ignoreList as player.Character before, I've been having some trouble with raycasting & ignoring as well.