This script hopefully isn’t sloppy or difficult to understand. I based this off of another persons script, however, theirs worked by detecting if the player moved in a certain direction, while mine uses velocity instead, not the best substitute, I’ve learned.
local runservice = game:GetService("RunService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local humanoidrootpart = character.PrimaryPart.AssemblyRootPart
local rootjoint = humanoidrootpart:WaitForChild("RootJoint")
local originalrootjointcframe = rootjoint.C0
local tilt = CFrame.new()
local maxtilt = 0.25
local tweeninfo = TweenInfo.new(0.08, Enum.EasingStyle.Sine)
local tweenservice = game:GetService("TweenService")
local LowerTorso = nil or character:FindFirstChild("LowerTorso")
local r6 = false
local r15 = false
if LowerTorso == nil then
local r6 = true
local r15 = false
else
local r6 = false
local r15 = true
end
runservice.Heartbeat:Connect(function(delta)
if humanoid.Health <= 0 then
return
end
if humanoid.PlatformStand then
return
end
local moveDirection = humanoidrootpart.CFrame:VectorToObjectSpace(character.PrimaryPart.Velocity)
tilt = tilt:Lerp(CFrame.Angles(math.rad(-moveDirection.Z) * maxtilt, math.rad(-moveDirection.X) * maxtilt, 0), 10 * delta)
local newcframe = originalrootjointcframe * tilt
local goal = {C0 = newcframe}
tweenservice:Create(rootjoint, tweeninfo, goal):Play()
end)
I also added an extra tween, which you can remove if you don’t like.