Greetings, Gentlemen.
-
I Want to make a climbing system that can climb from all faces of the part.
-
It will only work if I try to stick to the face where the look vector of the wall will be looking at me, I Do not want that, However, I Want it to work on all faces of the part.
The problem is probably because of the construction of the Coordinated Frame, I Do not know what to edit to achieve what I wish.
local Player = game.Players:GetPlayerFromCharacter(script.Parent)
local Character = Player.Character or Player.CharacterAdded:Wait()
local RunService = game:GetService("RunService")
local RaycastParameters = RaycastParams.new()
RaycastParameters.FilterDescendantsInstances = {Character}
RaycastParameters.FilterType = Enum.RaycastFilterType.Exclude
local debounce = false -- Add a debounce variable
local function StickToWall()
if debounce then return end -- Check if debounce is true, if so, return
local RaycastResult = workspace:Raycast(Character.PrimaryPart.Position, Character.PrimaryPart.CFrame.LookVector.Unit * 2, RaycastParameters)
if RaycastResult then
if RaycastResult.Instance:HasTag("ClimbablePart") and Character.Climbing.Value ~= true then
print("Sticking to the wall at:", RaycastResult.Position)
local WorldUp = Character:GetPrimaryPartCFrame().UpVector
local Normal = RaycastResult.Normal
local LookVector = Normal * -1
local RightVector = Normal:Cross(WorldUp)
local NeededCFrame = CFrame.fromMatrix(RaycastResult.Position - Vector3.new(0, 0, -1), RightVector, WorldUp, -LookVector)
game.ReplicatedStorage["Climbing Resever."]:FireServer(NeededCFrame, RaycastResult.Instance)
--local Character = Player.Character or Player.CharacterAdded:Wait()
--Character.PrimaryPart.CFrame = NeededCFrame
end
end
end
local function OnStepped()
StickToWall()
end
-- Connect the function to the Stepped event
RunService.RenderStepped:Connect(OnStepped)