I made a wall run script that works perfectly with R15 but for some reason doesn’t work with R6 please help.
Problem:
video
Code:
local character = game.Players.LocalPlayer.Character or script.Parent
local humanoidRootPart = character.PrimaryPart
local humanoid = character:FindFirstChildOfClass("Humanoid")
local ava = true
local has = false
local hold = false
local right = false
local left = false
--// Animations If Any \\--
local rightPlaying = false
local leftPlaying = false
local RA = humanoid:LoadAnimation(script:WaitForChild("RunRightAnimation"))
local LA = humanoid:LoadAnimation(script:WaitForChild("RunLeftAnimation"))
local vel = Instance.new("BodyVelocity", humanoidRootPart)
local gyr = Instance.new("BodyGyro", humanoidRootPart)
gyr.D = 100
gyr.P = 10000
gyr.MaxTorque = Vector3.new(0, 0, 0)
gyr.Name = "Rot"
vel.MaxForce = Vector3.new(0, 0, 0)
vel.Name = "Vel"
local TweenService = game:GetService("TweenService")
function ChangeCameraOffset(Offset)
local Humanoid = character:WaitForChild("Humanoid")
local Tween = TweenService:Create(Humanoid, TweenInfo.new(0.1), {CameraOffset = Offset})
Tween:Play()
end
function render()
local ray = Ray.new(humanoidRootPart.CFrame.p, humanoidRootPart.CFrame.rightVector * -2)
local ray2 = Ray.new(humanoidRootPart.CFrame.p, humanoidRootPart.CFrame.rightVector * 2)
local part, position, normal = workspace:FindPartOnRayWithIgnoreList(ray, {character})
local part2, position2, normal2 = workspace:FindPartOnRayWithIgnoreList(ray2, {character})
local cross = Vector3.new(0, 1, 0):Cross(normal)
local cross2 = Vector3.new(0, 1, 0):Cross(normal2)
if part and ava or part2 and ava then
--local canWallRun = part:FindFirstChild("WallRun") or part2:FindFirstChild("WallRun")
if part and part.Name == "WallRun" or part2 and part2.Name == "WallRun" then
if part then
humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.CFrame.p, Vector3.new(humanoidRootPart.Position.X + cross.X, humanoidRootPart.Position.Y, humanoidRootPart.Position.Z + cross.Z))
elseif part2 then
humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.CFrame.p, Vector3.new(humanoidRootPart.Position.X - cross2.X, humanoidRootPart.Position.Y, humanoidRootPart.Position.Z - cross2.Z))
end
has = true
hold = true
if hold then
gyr.CFrame = humanoidRootPart.CFrame
gyr.MaxTorque = Vector3.new(1, 1, 1) * math.huge
vel.MaxForce = Vector3.new(1, 1, 1) * math.huge
hold = false
if part then
vel.MaxForce = cross * 50
left = true
elseif part2 then
vel.MaxForce = -cross2 * 50
right = true
end
end
--// Start Camera \\--
ChangeCameraOffset(Vector3.new(0, 0, 0))
end
elseif ava and not part and not part2 and has and not hold then
gyr.MaxTorque = Vector3.new(0, 0, 0)
vel.MaxForce = Vector3.new(0, 0, 0)
ava = false
right = false
left = false
RA:Stop() LA:Stop()
--// Stop Camera \\--
ChangeCameraOffset(Vector3.new(0, 0, 0))
if has then
wait(0.5)
ava = true
has = false
end
end
if right and not rightPlaying then
RA:Play() rightPlaying = true
elseif not right then
RA:Stop() rightPlaying = false
end
if left and not leftPlaying then
LA:Play() leftPlaying = true
elseif not left then
LA:Stop() leftPlaying = false
end
end
game:GetService("RunService").RenderStepped:Connect(render)