RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Can you make a script that creates fluid head movement for the player?"
-- local script local RunService = game:GetService("RunService") local Players = game:GetService("Players") local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local head = character:WaitForChild("Head") local stiffness = 0.5 local damping = 0.5 local target = head.CFrame local velocity = Vector3.new(0, 0, 0) RunService.RenderStepped:Connect(function(deltaTime) if humanoid.Health > 0 then local goal = character.Torso.CFrame * CFrame.new(0, 1.5, 0) local position, rotation = head.CFrame:ToComponents() local goalPosition, goalRotation = goal:ToComponents() local newPosition = position:Lerp(goalPosition, stiffness * deltaTime) local newRotation = rotation:Slerp(goalRotation, stiffness * deltaTime) local newVelocity = (newPosition - position) / deltaTime velocity = newVelocity:Lerp(velocity, damping * deltaTime) head.CFrame = CFrame.new(newPosition, newPosition + velocity) * newRotation end end)