Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My camera bobbing script won’t work and I need some help fixing it, can anyone help me?

Asked by 4 years ago

Currently making a horror game where you explore, it’s locked in first person and every script I find doesn’t work, can anyone help me? I’d like it so when you walk the camera bobs and when you look around. The walk speed is 8 if you need it for the code. Thanks. The script I currently have is this


wait(0.1) 02 local cam = game.Workspace.CurrentCamera 03 local player = game.Players.LocalPlayer 04 local char = player.Character 05 local rs = game:GetService("RunService") 06 local lastTick = tick() 07 local t = 0 08 local headPos = char.Torso.Neck.C0 09 local running = false 10 11 char.Humanoid.Running:connect(function(speed) 12 running = speed > 0 13 end) 14 15 while true do 16 rs.RenderStepped:wait() 17 local dt = tick()-lastTick 18 if running then 19 t = t+dt 20 21 char.Torso.Neck.C0 = headPos * CFrame.new(math.cos(t*8)*0.1, 0, math.abs(math.sin(t*8))*0.1) 22 local look = cam.CoordinateFrame.lookVector 23 cam.CoordinateFrame = CFrame.new(cam.CoordinateFrame.p, cam.CoordinateFrame.p+look) * CFrame.Angles(0, 0, math.rad(math.cos(t*8))) 24 end 25 lastTick = tick() 26 end
0
Your code is very messy, bud. Remove the numbers and open the output tab to see any errors. Tell me any errors that happen with @Sensei_Developer Sensei_Developer 298 — 4y

Answer this question