Hello I’ve started yesterday working on a wall climb system Its almost done but the only problem i’m trying to make the player climb around a wall
this is what i want to achieve: https://gyazo.com/ecaff3fb9efaccaf4b6300c4bad51554
this is what i have currently: https://gyazo.com/70b810dae528efdc2b96d2f580f66720
this is the code I made:
--// Services
local UIS = game:GetService('UserInputService')
--// Variables
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local Root = Char:WaitForChild('HumanoidRootPart')
local Head = Char:WaitForChild('Head')
--// Settings
local HittingWall = false
local OnWall = false
local HoldingW = false
local Normal
local Pos
local Wall
local previousWall
--// Tables/Dictionnaries
local Movement = {
MovingUp = false,
MovingDown = false,
MovingRight = false,
MovingLeft = false
}
--// Animations
local Idle = Char:WaitForChild('Humanoid'):LoadAnimation(script:WaitForChild('Idle'))
local MU = Char:WaitForChild('Humanoid'):LoadAnimation(script:WaitForChild('MU'))
local MD = Char:WaitForChild('Humanoid'):LoadAnimation(script:WaitForChild('MD'))
local ML = Char:WaitForChild('Humanoid'):LoadAnimation(script:WaitForChild('ML'))
local MR
local JU = Char:WaitForChild('Humanoid'):LoadAnimation(script:WaitForChild('JU'))
-- Ray casting and Stop RayCasting if you
spawn(function()
while true do
local r = Ray.new(Head.CFrame.p, Head.CFrame.LookVector * 5)
local hit,pos,normal = workspace:FindPartOnRay(r,Char)
local r2 = Ray.new(Root.CFrame.p, Root.CFrame.RightVector * 5)
if hit then
if hit:FindFirstChild('Climable') then
print(hit.Name)
HittingWall = true
Pos = pos
Normal = normal
Wall = hit
previousWall = hit
end
end
if not hit then
if Root:FindFirstChild('bv') and OnWall then
Idle:Stop()
JU:Play()
MU:Stop()
MD:Stop()
ML:Stop()
local bv = Root:FindFirstChild('bv')
bv.Velocity = Vector3.new(0,0,0)
bv.Velocity = Root.CFrame.LookVector * 10 + Vector3.new(0, 40, 0)
game.Debris:AddItem(bv,.15)
OnWall = false
Char.Humanoid.AutoRotate = true
Char.Humanoid.PlatformStand = false
elseif Root:FindFirstChild('bv') == nil and OnWall then
Idle:Stop()
JU:Play()
MU:Stop()
MD:Stop()
ML:Stop()
local bv = Instance.new('BodyVelocity',Root)
bv.MaxForce = Vector3
bv.Velocity = Root.CFrame.LookVector * 10 + Vector3.new(0, 40, 0)
game.Debris:AddItem(bv,.15)
OnWall = false
Char.Humanoid.AutoRotate = true
Char.Humanoid.PlatformStand = false
end
--HittingWall = false
Pos = nil
Normal = nil
end
wait()
end
end)
-- Movement and Start/Stop Climbing
UIS.InputBegan:Connect(function(Key,Chatting)
if Key.KeyCode == Enum.KeyCode.X and not Chatting then
if HittingWall == true then
if not OnWall then
if Normal == nil then return end
OnWall = true
Idle:Play()
local bv = Instance.new('BodyVelocity',Root)
bv.MaxForce = Vector3.new(1,1,1) * math.huge
bv.Velocity = Root.CFrame.LookVector * 0
bv.Name = 'bv'
Char.Sit = true
Char.Humanoid.AutoRotate = false
Char.Humanoid.PlatformStand = true
else
Idle:Stop()
Root:FindFirstChild('bv'):Destroy()
Char.Humanoid.AutoRotate = true
Char.Humanoid.PlatformStand = false
OnWall = false
end
end
elseif Key.KeyCode == Enum.KeyCode.W and not Chatting then
if HittingWall == true then
if OnWall then
Idle:Stop()
MU:Play()
local bv = Root:FindFirstChild('bv')
bv.Velocity = Root.CFrame.LookVector * 0 + Vector3.new(bv.Velocity.X, 12.5, bv.Velocity.Z)
end
end
elseif Key.KeyCode == Enum.KeyCode.S and not Chatting then
if HittingWall == true then
if OnWall then
Idle:Stop()
MD:Play()
local bv = Root:FindFirstChild('bv')
bv.Velocity = Root.CFrame.LookVector * 0 + Vector3.new(bv.Velocity.X, -12.5, bv.Velocity.Z)
end
end
elseif Key.KeyCode == Enum.KeyCode.A and not Chatting then
if HittingWall == true then
if OnWall then
Idle:Stop()
ML:Play()
local bv = Root:FindFirstChild('bv')
bv.Velocity = Root.CFrame.LookVector * 0 + Vector3.new(bv.Velocity.X, bv.Velocity.Y, -12.5)
end
end
elseif Key.KeyCode == Enum.KeyCode.D and not Chatting then
if HittingWall == true then
if OnWall then
Idle:Stop()
--MU:Play()
local bv = Root:FindFirstChild('bv')
bv.Velocity = Root.CFrame.LookVector * 0 + Vector3.new(bv.Velocity.X, bv.Velocity.Y, 12.5)
end
end
end
end)
UIS.InputEnded:Connect(function(Key,Chatting)
if Key.KeyCode == Enum.KeyCode.W and OnWall then
Idle:Play()
MU:Stop()
local bv = Root:FindFirstChild('bv')
bv.Velocity = Root.CFrame.LookVector * 0 + Vector3.new(bv.Velocity.X, bv.Velocity.Y - 12.5, bv.Velocity.Z)
elseif Key.KeyCode == Enum.KeyCode.S and OnWall then
Idle:Play()
MD:Stop()
local bv = Root:FindFirstChild('bv')
bv.Velocity = Root.CFrame.LookVector * 0 + Vector3.new(bv.Velocity.X, bv.Velocity.Y + 12.5, bv.Velocity.Z)
elseif Key.KeyCode == Enum.KeyCode.D and OnWall then
Idle:Play()
local bv = Root:FindFirstChild('bv')
bv.Velocity = Root.CFrame.LookVector * 0 + Vector3.new(bv.Velocity.X, bv.Velocity.Y, bv.Velocity.Z - 12.5)
elseif Key.KeyCode == Enum.KeyCode.A and OnWall then
Idle:Play()
ML:Stop()
local bv = Root:FindFirstChild('bv')
bv.Velocity = Root.CFrame.LookVector * 0 + Vector3.new(bv.Velocity.X, bv.Velocity.Y, bv.Velocity.Z + 12.5)
end
end)
there is also another probleme when i use the body velocity it doesnt work good on other side