How can I check if a player has gotten of the wall from wall running?

Hello!
I’m trying to create a wall running system (like tria.os) currently I’m stuck on trying to get the player to fall off when the wall ends

Here is the code

local ray = Ray.new(RootPart.Position, RootPart.CFrame.LookVector * 1.7)
		local hit, point, normal = workspace:FindPartOnRay(ray, script.Parent)
		local hitTag = hit and hit:FindFirstChild("_WallRunSide")
		local Position = CHECK_SCALE(hit)
		if hitTag then
			-- Temporarily attach the Humanoid to the wall.
			local normalCFrame = hit.CFrame:ToObjectSpace(CFrame.new(Vector3.new(0, 0, 0), normal))
			normalCFrame = normalCFrame - normalCFrame.Position
			local offsetCFrame = CFrame.new((hit.CFrame:inverse() * RootPart.CFrame).Position)
			local newCFrame = hit.CFrame * offsetCFrame * normalCFrame

			RootPart.CFrame = newCFrame
			GripLookVector = newCFrame.LookVector
			OldWalkspeed = Humanoid.WalkSpeed
			Humanoid.WalkSpeed = 0
	
			CurrentConstraint = hit
			local de = true
			local Zone = require(game.ReplicatedStorage.Modules:WaitForChild("Zone"))
			local zone = Zone.new(hit)
			if de then
				de = false
				local BodyV = Instance.new("BodyVelocity")
				BodyV.Name = "WallSideRun"
				BodyV.Parent = Humanoid.RootPart
				BodyV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
				if Position.Y == 0 then
					if Position.Z > 0 and Position.X > Position.Z then
						BodyV.Velocity = Vector3.new(0, 0, 50)
					elseif Position.Z < 0 and Position.X > Position.Z then
						BodyV.Velocity = Vector3.new(0, 0, -50)
					else
						if Position.X > 0 then
							BodyV.Velocity = Vector3.new(50, 0, 0)
						elseif Position.X < 0 then
							BodyV.Velocity = Vector3.new(-50, 0, 0)
						end
					end
				else
					BodyV:Destroy()
				end
				de = true
			end
			
			--game.Debris:AddItem(CurrentAttachment, WallGripDuration + 1)
			--game.Debris:AddItem(CurrentConstraint, WallGripDuration + 1)

			WallJumpSound.SoundId = WallAttachSoundURL
			WallJumpSound:Play()
			WallJumpAnimTrack:Play()

			JumpWait = JumpCooldown
			game:GetService("UserInputService").InputBegan:Connect(function(input)
				if input.KeyCode == Enum.KeyCode.Space then
					if CurrentConstraint ~= nil then
						jumped = true
					end
				end
			end)
			repeat 
				wait()
			until jumped
			if jumped then
				LoseGrip()
				for i, v in pairs(game.Players.LocalPlayer.Character:GetDescendants()) do
					if v:IsA("BodyVelocity") then
						v:Destroy()
					end
				end
				-- Propel the character away from the wall.
				WallJumpSound.SoundId = WallJumpSoundURL
				WallJumpSound:Play()
				RootPart.Velocity =
					RootPart.Velocity +
					Vector3.new(0, Humanoid.JumpPower * 1.1, 0) +
					(GripLookVector * Humanoid.JumpPower)
				jumped = false
			end
		end

Not sure what you mean by fall off, but assuming your code is looping, if the ray doesn’t hit a part it should stop the characters movement on the walls once the wall is no longer being detected. your code is pretty good by the way.

Hey so long story short… I redone my code and it has been fixed lol, but thanks for the help.

Oh, alright then. Your code helped me out so just wanted to assist how I could. Thanks also.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.