Hey there devs.
So I got this bobble script I’ve been working on and I’m trying to implement rotation to it.
I scripted a bit then did a bit of bug fixing and editing.
Right now I’m getting this error.
Rotation cannot be assigned to
local runService = game:GetService("RunService")
local tweenService = game:GetService("TweenService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
camera.CameraSubject = character:WaitForChild("Head")
local jumpswaygoal = Instance.new("CFrameValue")
function updateBobbleEffect()
if humanoid.FloorMaterial ~= Enum.Material.Air then
local currentTime = tick()
if humanoid.MoveDirection.Magnitude > 0 then -- we are not standing still
if not _G.Sprinting then -- we are walking
local bobbleX = math.cos(currentTime * 5) * .1
local bobbleY = math.abs(math.sin(currentTime * 6)) * .2
local bobbleRotate = math.cos(currentTime * 2) * .1
local bobblePos = Vector3.new(bobbleX, bobbleY, 0)
local bobbleRot = CFrame.new(0, 0, bobbleRotate)
humanoid.CameraOffset = humanoid.CameraOffset:Lerp(bobblePos, 0.15)
camera.CFrame.Rotation = camera.CFrame.Rotation:Lerp(bobbleRot, 0.15)
elseif _G.Sprinting then -- we are sprinting
humanoid.CameraOffset = humanoid.CameraOffset * 1
local bobbleX = math.cos(currentTime * 7) * .4
local bobbleY = math.abs(math.sin(currentTime * 9)) * .6
local bobble = Vector3.new(bobbleX, bobbleY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:Lerp(bobble, .25)
end
else
local speed = currentTime * 1 -- higher = faster bob
local distance = .15 -- change for more drastic movement higher = more
local bobbleY = math.abs(math.sin(speed)) * distance
local bobble = Vector3.new(0, bobbleY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, .2)
end
end
end
runService.RenderStepped:Connect(updateBobbleEffect)
Any help is highly appreciated!