Hello, I can’t walllclimb after wallrunning, can anyone help? Thanks!
Video:
wallclimb script:
local c = script.Parent
local holdingKey = false
local wallClimbTimer = 0
local maxWallClimbTime = 1.5
local fallThreshold = 3
local canWallclimb = false
local hasWallClimbed = false
local inAir = false
local Jumped = false
local UIS = game:GetService("UserInputService")
local ClimbAnim = c.Humanoid:LoadAnimation(script:WaitForChild("ClimbAnim"))
local WallClimbSound = game.ReplicatedStorage.Sounds.WallclimbSound
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local originalWalkSpeed = c.Humanoid.WalkSpeed
hum.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Freefall then
inAir = true
elseif newState == Enum.HumanoidStateType.Landed then
inAir = false
hasWallClimbed = false
elseif newState == Enum.HumanoidStateType.Jumping then
Jumped = true
end
end)
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local wallClimbLabel = Instance.new("TextLabel")
wallClimbLabel.Name = "CooldownLabel"
wallClimbLabel.Text = ""
wallClimbLabel.Font = Enum.Font.Jura
wallClimbLabel.TextScaled = true
wallClimbLabel.TextSize = 30
wallClimbLabel.Size = UDim2.new(0, 200, 0, 50)
wallClimbLabel.Position = UDim2.new(0.5, -100, 0, 825)
wallClimbLabel.TextColor3 = Color3.new(1, 1, 1)
wallClimbLabel.BackgroundTransparency = 0.5
wallClimbLabel.BackgroundColor3 = Color3.new(1, 1, 0)
wallClimbLabel.BorderSizePixel = 0
wallClimbLabel.Parent = screenGui
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then return end
if input.KeyCode == Enum.KeyCode.Space and inAir then
if canWallclimb and not hasWallClimbed then
holdingKey = true
wallClimbTimer = 0
canWallclimb = false
originalWalkSpeed = c.Humanoid.WalkSpeed
task.wait(0.1)
wallClimbLabel.Visible = true
end
end
end)
UIS.InputEnded:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then return end
if input.KeyCode == Enum.KeyCode.Space then
holdingKey = false
--canWallclimb = true
end
end)
game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {c}
raycastParams.IgnoreWater = true
local rayUp = workspace:Raycast(c.HumanoidRootPart.Position, c.HumanoidRootPart.CFrame.LookVector * 1.5, raycastParams)
local rayDown = workspace:Raycast(c.HumanoidRootPart.Position, -c.HumanoidRootPart.CFrame.UpVector * fallThreshold, raycastParams)
local ray = rayUp
if rayDown and not ray and not canWallclimb then
canWallclimb = true
end
if ray and holdingKey and not canWallclimb then
if not ClimbAnim.IsPlaying then
ClimbAnim:Play()
plr:SetAttribute("WallClimbing", true)
end
local wallNormal = ray.Normal
local lookDirection = -wallNormal
local upVector = Vector3.new(0, 1, 0)
c.HumanoidRootPart.CFrame = CFrame.lookAt(c.HumanoidRootPart.Position, c.HumanoidRootPart.Position + lookDirection, upVector)
wallClimbTimer = wallClimbTimer + deltaTime
local cooldownTime = maxWallClimbTime - wallClimbTimer
wallClimbLabel.Text = string.format("%.1fs", cooldownTime)
local part = ray.Instance
local weld = c.HumanoidRootPart:FindFirstChild("WallclimbWeld") or Instance.new("WeldConstraint")
weld.Name = "WallclimbWeld"
weld.Part0 = c.HumanoidRootPart
weld.Part1 = part
local bp = c.HumanoidRootPart:FindFirstChild("WallclimbBodyPosition") or Instance.new("BodyPosition", c.HumanoidRootPart)
bp.Name = "WallclimbBodyPosition"
bp.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bp.Position = c.HumanoidRootPart.Position + c.HumanoidRootPart.CFrame.UpVector * c.Humanoid.WalkSpeed / 3
if wallClimbTimer >= maxWallClimbTime then
holdingKey = false
canWallclimb = true
hasWallClimbed = true
end
if not WallClimbSound.IsPlaying then
WallClimbSound:Play()
end
else
for i, child in pairs(c.HumanoidRootPart:GetChildren()) do
if child.Name == "WallclimbWeld" or child.Name == "WallclimbBodyPosition" then
c.Humanoid.WalkSpeed = originalWalkSpeed
child:Destroy()
end
end
plr:SetAttribute("WallClimbing", false)
ClimbAnim:Stop()
wallClimbTimer = 0
if WallClimbSound.IsPlaying then
WallClimbSound:Stop()
end
wallClimbLabel.Text = ""
wallClimbLabel.Visible = false
end
end)
wallrun script:
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
wait(0.5)
local module = require(script.ModuleScript)
local inputServ = game:GetService("UserInputService")
local head = plr.Character:FindFirstChild("Head")
local torso = plr.Character:FindFirstChild("Torso")
local root = plr.Character:FindFirstChild("HumanoidRootPart")
local runServ = game:GetService("RunService")
local defaultGravity = workspace.Gravity
local sett = script.Settings
local wallrunSound = game.ReplicatedStorage.Sounds.WallRunSound
local releseSound = game.ReplicatedStorage.Sounds.JumpSound
local landed = true
local holdingSpace = false
local wallranL = false
local wallranR = false
local wallranB = false
local leftAnim = Instance.new("Animation")
leftAnim.AnimationId = "rbxassetid://16303089762"
local leftAnimTrack = hum:LoadAnimation(leftAnim)
local rightAnim = Instance.new("Animation")
rightAnim.AnimationId = "rbxassetid://16303092892"
local rightAnimTrack = hum:LoadAnimation(rightAnim)
hum.StateChanged:Connect(function(old,new)
if new == Enum.HumanoidStateType.Freefall or new == Enum.HumanoidStateType.Jumping then
landed = false
elseif new == Enum.HumanoidStateType.Landed then
landed = true
wallranL = false
wallranR = false
wallranB = false
end
end)
inputServ.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Space or input.KeyCode == Enum.KeyCode.ButtonA then
holdingSpace = true
end
end)
inputServ.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Space or input.KeyCode == Enum.KeyCode.ButtonA then
holdingSpace = false
end
end)
local last = tick()
runServ.RenderStepped:Connect(function()
local t = tick()
local dt = t - last
last = t
local RPart,RPosition = module.Ray(root.Position,root.CFrame.XVector * 5,plr.Character)
local LPart,LPosition = module.Ray(root.Position,root.CFrame.XVector * -5,plr.Character)
if LPart and not RPart and not landed and holdingSpace and torso.Velocity.Y > -35 and torso.Velocity.Y < -1 then
torso.Velocity = torso.Velocity + Vector3.new(0,-0,0) *dt
workspace.Gravity = workspace.Gravity + (workspace.Gravity-5) *dt
if not wallranL then
leftAnimTrack:Play()
workspace.Gravity = 10
wallrunSound:Play()
wallranL = true
plr.Character:SetAttribute("WallRunning", true)
--print(plr.Character:GetAttribute("WallRunning"))
end
elseif not LPart and RPart and not landed and holdingSpace and torso.Velocity.Y > -35 and torso.Velocity.Y < -1 then
torso.Velocity = torso.Velocity + Vector3.new(0,0,0) *dt
workspace.Gravity = workspace.Gravity + (workspace.Gravity-5) *dt
if not wallranR then
rightAnimTrack:Play()
workspace.Gravity = 10
wallrunSound:Play()
wallranR = true
plr.Character:SetAttribute("WallRunning", true)
--print(plr.Character:GetAttribute("WallRunning"))
end
elseif RPart and LPart and not landed and holdingSpace and torso.Velocity.Y > -35 and torso.Velocity.Y < -1 then
torso.Velocity = torso.Velocity + Vector3.new(0,0,0) *dt
workspace.Gravity = workspace.Gravity + (workspace.Gravity-5) *dt
if not wallranB then
workspace.Gravity = 10
wallrunSound:Play()
wallranB = true
plr.Character:SetAttribute("WallRunning", true)
--print(plr.Character:GetAttribute("WallRunning"))
end
elseif landed or not holdingSpace or (not RPart and not LPart) or (torso.Velocity.Y < -35 and torso.Velocity.Y < -1) then
if leftAnimTrack.IsPlaying or rightAnimTrack.IsPlaying then
torso.Velocity = Vector3.new(torso.Velocity.X,sett.WallRunningEndingVelocity.Value,torso.Velocity.Z)
end
workspace.Gravity = defaultGravity
leftAnimTrack:Stop()
rightAnimTrack:Stop()
wallrunSound:Stop()
plr.Character:SetAttribute("WallRunning", false)
--releseSound:Play()
end
end)