I want to make the player model tilt towards the direction the player is moving (the quicker it changes direction, the more the player model tilts) and I don't really know how to do either (detect change in direction and tilt player model) could anyone help? Cheers!
you can simply use the Y component of the HumanoidRootPart's RotVelocity to find the speed the player is rotating at, then base the amount of tilt on that number
to actually apply the tilt, you can change the Transform of the character's root joint
where that joint is located and what it's called depends on whether your game is r6 or r15
if you want it to appear smooth you can repeatedly lerp the Transform instead of just constantly setting it
-- LocalScript in StarterCharacterScripts local RunService = game:GetService("RunService") local char = script.Parent local rootPart = char:WaitForChild("HumanoidRootPart") local rootJoint = rootPart:WaitForChild("RootJoint") -- change this to char:WaitForChild("LowerTorso"):WaitForChild("Root") if your game uses R15 -- if your game supports both you'll have to check to see which the character uses with Humanoid.RigType local transform = CFrame.new() local originalC0 = rootJoint.C0 rootJoint:GetPropertyChangedSignal("C0"):Connect(function() -- account for changes to the C0 made by actual roblox scripts if rootJoint.C0 ~= originalC0 * transform then originalC0 = rootJoint.C0 end end) RunService.RenderStepped:Connect(function(delta) local tilt = math.clamp(rootPart.RotVelocity.Y * 4, -45, 45) transform = transform:Lerp(CFrame.Angles(0, math.rad(tilt), 0), 0.25 * delta * 60) -- you can change 0.25 here to whatever you want rootJoint.C0 = originalC0 * transform end)
if you want other people to be able to see tilt as well, you can copy and paste the same code into a server script, but with RenderStepped replaced with Heartbeat