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

How to make an idle camera bobbing script?

Asked by
yelsew 205 Moderation Voter
8 years ago

I have a camera bobbing script when moving, I just need one for when it's idle. And yes, I took and edited the code from a different page on here. If your curious, I'm not making a TDM game. Maybe later. I've tried using an else, but that doesn't seem to work.

repeat wait(0.1) until game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character
local runservice = game:GetService("RunService")
local lastTick = tick()
local t = 0
local running = false

character.Humanoid.Running:connect(function(speed)
    running = speed > 0
end)

while true do
    runservice.RenderStepped:wait()
    local dt = tick()-lastTick
    if running then
        t = t+dt
        local look = camera.CoordinateFrame.lookVector
        camera.CoordinateFrame = CFrame.new(camera.CoordinateFrame.p, camera.CoordinateFrame.p+look) * CFrame.Angles(0, 0, math.rad(math.cos(t*6)))
    end
    lastTick = tick()
end

This is my current code, and I'd prefer (not require) that whoever answers expand on this. Thanks!

0
This looks very interesting! Needless to say, I can't help you with it because of lack of skill. RadiantSolarium 35 — 8y
0
That's fine, and once again it is an edited version of a chunk of code found on this site. yelsew 205 — 8y

Answer this question