Help with wall run script?

Heyo I’m trying to make a wall run script and I watched a tutorial on how to make one however I’ve been trying to adjust it to make it work with user input, but I can’t seem to get it to work or at least it doesn’t seem to work very well so how can I improve this?

The Input doesn’t seem to work at all with the renderstepped even though I’m changing the hold value it still says it’s false when printing it in the render function and yeah.

local Player = Playes.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
local Hold = false
local Ava = true
local Has = false
local BodyVelocity = Instance.new("BodyVelocity",HRP)
local BodyGyro = Instance.new("BodyGyro",HRP)
BodyGyro.D = 100
BodyGyro.P = 10000
BodyGyro.MaxTorque = Vector3.new(0,0,0)
BodyGyro.Name = "Rot"
BodyVelocity.MaxForce = Vector3.new(0,0,0)
BodyVelocity.Name = "Vel"

UIS.InputBegan:Connect(function(Input, IsTyping)
	if IsTyping then return end

	if Input.KeyCode == Enum.KeyCode.W then
		Hold = true
	end
end)

UIS.InputEnded:Connect(function(Input, IsTyping)
	if IsTyping then return end

	if Input.KeyCode == Enum.KeyCode.W then
		Hold = false
	end
end)

function Render()
	local Ray1 = Ray.new(HRP.CFrame.p,HRP.CFrame.rightVector * -3)
	local Ray2 = Ray.new(HRP.CFrame.p,HRP.CFrame.rightVector * 3)
	local Part1,Position2,Normal1 = workspace:FindPartOnRayWithIgnoreList(Ray1,{Character})
	local Part2,Position2,Normal2 = workspace:FindPartOnRayWithIgnoreList(Ray2,{Character})
	local Cross1 = Vector3.new(0,1,0):Cross(Normal1)
	local Cross2 = Vector3.new(0,1,0):Cross(Normal2)
	
	if (Part1 and Ava) or (Part2 and Ava) then -- Player is touching a part
		if Normal1.y == 0 or Normal2.y == 0 then --Not exactly sure what any of this does
			if Part1 then
				HRP.CFrame = CFrame.new(HRP.CFrame.p,Vector3.new(HRP.Position.X + Cross1.x,HRP.Position.Y,HRP.Position.Z + Cross1.z))
			elseif Part2 then
				HRP.CFrame = CFrame.new(HRP.CFrame.p,Vector3.new(HRP.Position.X - Cross2.x,HRP.Position.Y,HRP.Position.Z - Cross2.z))
			end
		end

		Has = true
		if Hold then
			--Moves player
			BodyGyro.CFrame = HRP.CFrame
			BodyGyro.MaxTorque = Vector3.new(1,1,1) * math.huge
			BodyVelocity.MaxForce = Vector3.new(1,1,1) * math.huge
			if Part1 then
				BodyVelocity.Velocity = Cross1 * 50
				Left = true
			elseif Part2 then
				BodyVelocity.Velocity = -Cross2 * 50
				Right = true
			end
		else
		        --Stops moving the player
			BodyGyro.MaxTorque = Vector3.new(0,0,0)
			BodyVelocity.MaxForce = Vector3.new(0,0,0)		
			Ava = false
			Left = false
			Right = false
			if Has then
				wait(0.5)
				Ava = true
				Has = false
			end
		end
	elseif (Ava and not Part1 and not Part2 and Has) then --Player is no longer touching a part
		--Stops moving the player
		BodyGyro.MaxTorque = Vector3.new(0,0,0)
		BodyVelocity.MaxForce = Vector3.new(0,0,0)		
		Ava = false
		Left = false
		Right = false
		if Has then
			wait(0.5)
			Ava = true
			Has = false
		end
	end
end
2 Likes

a mistake here

local Player = Playes.LocalPlayer

should be

local Player = game.Players.LocalPlayer

Oh my bad I just didn’t include the entire script, but I have my services at the top of the script

--| Services
local Playes = game:GetService("Players")
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")

Even with the services it would not work. You made a small spelling mistake here:

local Player = Playes.LocalPlayer

Should be:

local Player = Players.LocalPlayer

Maybe that was the issue.