How could I make it so If touched changes Camera angle and field of view?
Asked by
6 years ago Edited 6 years ago
I'm trying to make a script that when the player walks through the door it changes their angle of view and etc. The first script is the "CameraChange" and the second one is in the door.
01 | local offset = Vector 3. new( 50 , 10 , 0 ) |
02 | local fieldOfView = 100 |
03 | local player = script.Parent.Parent |
04 | local camera = game.Workspace.CurrentCamera |
05 | local runService = game:GetService( "RunService" ) |
07 | camera.FieldOfView = fieldOfView |
08 | local function onRenderStep() |
10 | local playerPosition = player.Character.HumanoidRootPart.Position |
11 | local cameraPosition = playerPosition + offset |
12 | camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition) |
15 | runService:BindToRenderStep( 'Camera' , Enum.RenderPriority.Camera.Value, onRenderStep) |
1 | script.Parent.Touched:Connect( function (hit) |
2 | if hit.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
3 | local NewCam = game.Players:GetPlayerFromCharacter(hit.Parent).StarterPlayer.StarterPlayerScripts:WaitForChild( "CameraChange" ) |
5 | NewCam.Disabled = false |