CameraOffset Error

Huh? Can someone explain why this isnt working?

local module = {}

function module.SmallShake(character : Model, duration : number)
    if character == nil    or duration == nil then
        return
    end
    
    local Humanoid = character:FindFirstChild("Humanoid")
    
    task.spawn(function()
        local StartTime = os.time()
        
        repeat
            task.wait()
            
            local EndTime = os.time()
            
            local XOffset = math.random(-50, 50) / 800
            local YOffset = math.random(-50, 50) / 800
            local ZOffset = math.random(-50, 50) / 800
            
            Humanoid.CameraOffset = Vector3.new(XOffset, YOffset, ZOffset)
        until EndTime - StartTime >= duration
        
        Humanoid.CameraOffset = Vector3.zero
    end)
end

return module
local lp = game.Players.LocalPlayer
    
ScreenShake.SmallShake(game.Players.LocalPlayer, 5)
ReplicatedStorage.ScreenShake:22: attempt to index nil with 'CameraOffset'  -  Client - ScreenShake:22

The first argument you gave was the “LocalPlayer” not its character.

local lp = game.Players.LocalPlayer
    
ScreenShake.SmallShake(game.Players.LocalPlayer, 5)
1 Like

tysm… sometimes ig I just need to take a break lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.