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

Cannot access currentcamera could somebody help me understand?

Asked by 10 years ago

Could I have a script that would change the FieldOfView to 20, wait 3 seconds, and then change back to 70. I can't seem to get it working, even through a localscript. Here's what I did:

game.Players.PlayerAdded:connect(player)
    player.CharacterAdded:connect(char)
        local cam = Workspace.CurrentCamera
        cam.CameraType = 'Scriptable'
        cam.FieldOfView = 20
        wait(3)
        cam.FieldOfView = 70
    end)
end)

2 answers

Log in to vote
3
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Your problem is simple. You are not using anonymous functions correctly.

Instead of,

game.Players.PlayerAdded:connect(player)
    player.CharacterAdded:connect(char)
        --code
    end)
end)

It should be:

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(char)
        --code
    end)
end)
0
-Facepalm- This was late at night, ok? lol RedneckBane 100 — 10y
Ad
Log in to vote
-6
Answered by 10 years ago

PlayerAdded is not for a localscript.

game.Players.PlayerAdded:connect(player)

    player.CharacterAdded:connect(char)

        local cam = Workspace.CurrentCamera

        cam.CameraType = 'Scriptable'

        cam.FieldOfView = 20

        wait(3)

        cam.FieldOfView = 70

    end)

end)

My Profile on Roblox click here.

Answer this question