Hey all Dev’s,
I ran in to a problem with one of my scripts for my game that bobs the players screen when walking and running, the problem I have is that I want the bobbing to be more intense when running. Before hand I thought if I just made the script check the players walk speed and if it was over 30 then it would intensify the bobbing. And if it was less then 30 then it would lessen. But as I wrote it out is seems to not work. I just want to see how to write it out in such a way that I can get the result I want.
Thank you all for any help I can get on this madder.
local runService = game:GetService("RunService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local Player = game.Players.LocalPlayer
if Humanoid.WalkSpeed < 30 then
function updatedBobbleEffct()
local currentTime = tick()
if humanoid.MoveDirection.Magnitude > 0 then
local bobbleX = math.cos(currentTime * 0) * 1
local bobbleY = math.abs(math.sin(currentTime * 4)) * 1
local bobble = Vector3.new(bobbleX, bobbleY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, .25) --25
else
humanoid.CameraOffset = humanoid.CameraOffset * .75 --75
end
end
runService.RenderStepped:Connect(updatedBobbleEffct)
end
if Humanoid.WalkSpeed > 30 then
function updatedBobbleEffct()
local currentTime = tick()
if humanoid.MoveDirection.Magnitude > 0 then
local bobbleX = math.cos(currentTime * 0) * 1
local bobbleY = math.abs(math.sin(currentTime * 4)) * 1
local bobble = Vector3.new(bobbleX, bobbleY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, .05) --25
else
humanoid.CameraOffset = humanoid.CameraOffset * .1 --75
end
end
end
runService.RenderStepped:Connect(updatedBobbleEffct)
If you can, I would appreciate any help in showing what I’m doing wrong
.

