I’m making a wall climbing mechanic, and I need some help trying to figure out what face the wall is so that the player can snap onto a specific offset so that they can get onto the part.
Here is the code
-->> Wall Climbing <<--
local origin = character.PrimaryPart
local direction = origin.CFrame * CFrame.new(0, 0, -1)
local params = RaycastParams.new()
local rayPart = Instance.new("Part")
rayPart.Name = character.Name.." Ray Part"
rayPart.Anchored = true
rayPart.Material = Enum.Material.SmoothPlastic
rayPart.CanCollide = false
rayPart.Parent = workspace.Terrain
rayPart.Size = Vector3.new(1, 1, 2)
params.FilterDescendantsInstances = {character, rayPart}
params.FilterType = Enum.RaycastFilterType.Blacklist
params.IgnoreWater = true
while task.wait() do
rayPart.CFrame = direction
local origin = character.PrimaryPart.CFrame
local direction = origin * CFrame.new(0, 0, -2)
rayPart.CFrame = direction * CFrame.new(0, 0, 1)
local raycastResult = workspace:Raycast(origin.Position, direction.Position - origin.Position, params)
if raycastResult then
if raycastResult.Instance.Name == "ClimableWall" then
character.PrimaryPart.CFrame = CFrame.new(raycastResult.Position)
end
end
end