I found this free model R15 torso camera movement script. It works great (iron sights track better than my older one), but I want to know how to make it run smoother, or at least less choppy. It has a script with “tweens” and from my understanding “tries” to make it run smoother, but doesn’t really work. I don’t know what tweens are or do, so help?
BodyMovementScript:
if not script.Parent:FindFirstChild("Humanoid") then
script.Parent = game.StarterPlayer.StarterCharacterScripts
return
end
local tweenService = game:GetService("TweenService")
local remote = Instance.new("RemoteEvent", script)
remote.Name = "Remote"
local enabled = script.Enabled
local debounce = tick()
local lastDirection = 0
remote.OnServerEvent:connect(function(player, mouseDirection, waist, waistPosition)
if player then
if tick()-debounce <= 0.1 then return end;
debounce = tick();
if enabled.Value then
lastDirection = mouseDirection
tweenService:Create(waist, TweenInfo.new(0.099), {C1=(CFrame.new(Vector3.new(-0, waistPosition, -0.000272244215)) * CFrame.Angles(mouseDirection, 0, 0))}):Play();
elseif lastDirection ~= 0.054 then
lastDirection = 0.054
tweenService:Create(waist, TweenInfo.new(0.099), {C1=(CFrame.new(Vector3.new(-0, waistPosition, -0.000272244215)) * CFrame.Angles(0.054, 0, 0))}):Play();
end
end
end)
BodyMovementLocal:
local player = game.Players.LocalPlayer;
local runService = game:GetService("RunService").Heartbeat;
local tweenService = game:GetService("TweenService");
local playerMouse = player:GetMouse();
local remote = script.Parent:WaitForChild("Remote");
wait(2)
local character = player.Character;
local humanoid = character:FindFirstChild("Humanoid");
local torso = character:FindFirstChild("UpperTorso");
local waist = torso ~= nil and torso:FindFirstChild("Waist") or nil;
local waistPosition = torso ~= nil and torso:FindFirstChild("WaistRigAttachment") or nil;
waistPosition = waistPosition.Position.Y
local lastMousePosition = playerMouse.UnitRay.Direction.unit;
local lastUpdate = tick();
runService:connect(function()
if torso ~= nil then
if waist ~= nil and lastMousePosition ~= playerMouse.UnitRay.Direction.unit then
local mouseDirection = playerMouse.UnitRay.Direction.unit;
if workspace.FilteringEnabled then
if tick()-lastUpdate >= 0.1 then
remote:FireServer(-math.asin(mouseDirection.y), waist, waistPosition);
end
end
lastMousePosition = playerMouse.UnitRay.Direction.unit;
else
waist = torso ~= nil and torso:FindFirstChild("Waist") or nil;
end
else
torso = character:FindFirstChild("UpperTorso");
end
end)