Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Cannot access currentcamera could somebody help me understand?

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

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)

1 comment

0

-Facepalm- This was late at night, ok? lol

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.