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