Pretty basic script, it’s just meant to sway the camera when you turn you’re camera. It however, doesn’t work. Any idea on why this is?:
-- Services --
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
-- Player & Camera --
local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera
-- Variables --
local turnAngle = 0
-- Lerp Function --
local function lerp(a, b, t)
return a + (b - a) * t
end
-- Camera Sway --
RunService:BindToRenderStep("CameraSway", Enum.RenderPriority.Camera.Value + 1, function(deltaTime)
local mouseDelta = UserInputService:GetMouseDelta()
turnAngle = lerp(turnAngle, math.clamp(mouseDelta.X, -6, 6), 6 * deltaTime)
Camera.CFrame = Camera.CFrame * CFrame.Angles(0, 0, math.rad(turnAngle))
end)
Sorry I didn’t get back to you sooner, can you send me you’re version of the script with that addition. I might just be confused but I tried to add it and it didn’t work.
-- Services --
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
-- Player & Camera --
local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera
-- Variables --
local turnAngle = 0
-- Lerp Function --
local function lerp(a, b, t)
return a + (b - a) * t
end
-- Camera Sway --
RunService:BindToRenderStep("CameraSway", Enum.RenderPriority.Camera.Value + 1, function(deltaTime)
local mouseDelta = UserInputService:GetMouseDelta()
local lerpspeed = 50
turnAngle = lerp(turnAngle, 0, 1 - math.exp(-lerpspeed * deltaTime))
Camera.CFrame = Camera.CFrame * CFrame.Angles(0, 0, math.rad(turnAngle))
end)
Here, I’ve read your script and the problem is well… because the mousedelta isn’t being used, at all!
-- Services --
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
-- Player & Camera --
local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera
-- Variables --
local turnAngle = 0
-- Lerp Function --
local function lerp(a, b, t)
return a + (b - a) * t
end
-- Camera Sway --
RunService:BindToRenderStep("CameraSway", Enum.RenderPriority.Camera.Value + 1, function(deltaTime)
local mouseDelta = UserInputService:GetMouseDelta()
local lerpspeed = 50
turnAngle = lerp(turnAngle, mouseDelta.X*10, 1 - math.exp(-lerpspeed * deltaTime))
Camera.CFrame = Camera.CFrame * CFrame.Angles(0, 0, math.rad(turnAngle))
end)