Hello, im currently working on a custom camera for a test game but it seems jittery, on the first game that is the game im trying to fix the camera on, the second game is where the camera is completely fine. In both games, the scripts are exactly the same but is delayed in the test game??
the script
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local RootPart,Head = Character:WaitForChild("HumanoidRootPart"),Character:WaitForChild("Head")
local Camera = workspace.CurrentCamera
-- [ Services ] --
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
-- [ Modules ] --
local Tween = require(ReplicatedStorage.Modules.Tween)
-- [ Data ] --
local TweenPower = 1750
local CameraStiffness = script:GetAttribute("CameraStiffness")
local CanRun = not UIS.TouchEnabled
local CameraBlock = Instance.new("Part", Character)
CameraBlock.Size = Vector3.new(1, 1, 1)
CameraBlock.Name = "CameraBlock"
CameraBlock.CastShadow = false
CameraBlock.CanTouch = false
CameraBlock.CanCollide = false
CameraBlock.Transparency = 1
CameraBlock.Position = Character.PrimaryPart.Position
local BodyPosition = Instance.new("BodyPosition", CameraBlock)
BodyPosition.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
-- [ Functions ] --
local function Loop()
BodyPosition.P = TweenPower * CameraStiffness
BodyPosition.Position = Head.CFrame.Position + Vector3.new(0, (Humanoid.HipHeight - script:GetAttribute("CameraHeight")), 0)
Camera.CameraSubject = CameraBlock
end
local function CameraOffset()
Humanoid.CameraOffset = (Head.CFrame + Vector3.new(0,1.5,0)):PointToObjectSpace(Head.CFrame.Position)
end
-- [ Code ] --
if CanRun then
RunService:BindToRenderStep("Smooth Camera", 201, Loop)
end