When making a ledge script, you need to:
- make the character cframe on the ledge of the part they climb on (got that)
- make the character rotate to the ledge so they’re aligned with it (don’t got that)
I’ve been scavenging around trying to figure out if anyone else has had an issue like this, but I’ve come to a realization that this has not been talked about before. If a player’s on the ledge of a part from where they jumped, how do I align their character to that specific edge? There’s 4 different edges on a part’s top surface, and the player’s not always going to be in the center of the part, so that’s where it confuses me.
Here’s an example of my code (part where it cframes them to the ledge):
local part = workspace:Raycast(head.CFrame.p, head.CFrame.LookVector * 2)
if part then
if head.Position.Y >= (part.Instance.Position.Y + (part.Instance.Size.Y / 2)) - 1 and head.Position.Y <= part.Instance.Position.Y + (part.Instance.Size.Y / 2) and humanoid.FloorMaterial == Enum.Material.Air and root.Velocity.Y <= 0 then
if ledgedebounce then return end
root.Anchored = true
root.CFrame = CFrame.new(part.Position.X, (part.Instance.Position.Y + (part.Instance.Size.Y/2)), part.Position.Z)
holding = true
ledgeavailable = false
if not ledgeTrack.IsPlaying then
ledgeTrack:Play()
end
end
else