Issues creating sliding system

Hello! I’m following a tutorial that details how to make a sliding system, but I ran into some roadblocks. For one, I’m getting an error with AlignOrientation: “Workspace.04robot48.OnSlide:101: attempt to index boolean with 'Enabled'” However, looking at the piece of code that throws the error, I’ve provided a boolean as AlignOrientation.Enabled requires.

      if not isInSlideMode then
			print("Sliding now")
			isInSlideMode = true
			
			alignOrientation.Enabled = true -- See here
			hrp.AssemblyLinearVelocity = Vector3.zero
			
			char.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
			ctrls:Disable()
			slidingAnimTrack:Play()
			
			local forwardForce = slopeVec.Unit * hrp.AssemblyMass * slideAcc
			hrp:ApplyImpulse(forwardForce)
			
			
			postMovementEv = game:GetService("RunService").Heartbeat:Connect(function(dt)
				timeSinceSlideStart += dt
				local linearVelo = hrp.AssemblyLinearVelocity
				hrp.AssemblyLinearVelocity = linearVelo - floorNormal * linearVelo:Dot(floorNormal)
				
				alignOrientation.CFrame = CFrame.lookAt(hrp.CFrame.Position, hrp.CFrame.Position + hrp.AssemblyLinearVelocity)
				
				if timeSinceSlideStart >= 0.2 then
					if (hrp.AssemblyLinearVelocity * Vector3.new(1,0,1)).Magnitude < 0.1 then
						print("Stopped slide. Reached velocity zero")
						reset()
						return
					end
				end
			end)
			

		end
External Media

Along with that, after sliding is finished, the character also constantly faces behind them. I think it’s also related to AlignOrientation, but I’m not sure. I can supply the entire code if need be. Thanks in advance

AlignOrientation locks the characters orientation after it applys. simply delete the instance after sliding finishes to avoid this.

as for this issue, it is seeing the variable alignOrientation as a boolean, are you sure the variable is set to an instance and not a boolean?

2 Likes

Oh, this fixed it! Earlier in the function for sliding, I accidentally wrote

alignOrientation = false

in the reset logic, instead of

alignOrientation.Enabled = false

Adding the Enabled fixed both the error and the alignment issue. Thanks for the heads up!

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