Underwater effect not working

    if Water ~= nil then
        FisheyeEffectAlpha = FisheyeEffectAlpha + deltaTime / FisheyeEffectCycleDuration
        FisheyeEffectAlpha = FisheyeEffectAlpha - math.floor(FisheyeEffectAlpha)
humCamOffset = humCamOffset + Vector3.new(math.sin(tick() * 3) * 0.2, math.sin(tick() * 3.21) * 0.2, math.sin(tick() * 3.73) * 0.2)+ Vector3.new(math.sin(tick() * 3) * 0.2, math.sin(tick() * 3.21) * 0.2, math.sin(tick() * 3.73) * 0.2)
        local camoffs = humCamOffset + Vector3.new(math.sin(tick() * 3) * 0.2, math.sin(tick() * 3.21) * 0.2, math.sin(tick() * 3.73) * 0.2)+ Vector3.new(math.sin(tick() * 3) * 0.2, math.sin(tick() * 3.21) * 0.2, math.sin(tick() * 3.73) * 0.2)
                player.Humanoid.CameraOffset = camoffs
    end
end)

This did not work. I tried doing everything. Please help

2 Likes

It says attempt to index nil with ‘Humanoid’ on line 6.

Try to do:

player.Character:WaitForChild("Humanoid").CameraOffset = camoffs

And now it gives me attempt to index nil with ‘WaitForChild’

Try this line of code:

player:WaitForChild(“Humanoid”).CameraOffset = camoffs

The issue is, the player object doesn’t have a Humanoid inside it, their Character does. Try replacing that with this:

if player.Character then
    --Make sure they have a character.
    player.Character:WaitForChild("Humanoid").CameraOffset = camoffs

If it doesn’t work, it likely means you haven’t stored the actual player object in variable player.
(Or it’s that I just woke up and am on my phone lol)

also, when i messed up my code, it gave me bad argument #1 (Vector3 expected, got nil)

   if Water ~= nil then
humCamOffset = humCamOffset + Vector3.new(math.sin(tick() * 3) * 0.2, math.sin(tick() * 3.21) * 0.2, math.sin(tick() * 3.73) * 0.2)+ Vector3.new(math.sin(tick() * 3) * 0.2, math.sin(tick() * 3.21) * 0.2, math.sin(tick() * 3.73) * 0.2)
                if player.Character then
    --Make sure they have a character.
    player.Character:WaitForChild("Humanoid").CameraOffset = humCamOffset

this is my code

on the 2nd line. i don’t know why.

humCamOffset is nil, initialize it with an empty Vector3 where it’s being defined