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

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.

01local offset = Vector3.new(50,10,0)
02local fieldOfView = 100
03local player = script.Parent.Parent
04local camera = game.Workspace.CurrentCamera
05local runService = game:GetService("RunService")
06 
07camera.FieldOfView = fieldOfView
08local function onRenderStep()
09 
10local playerPosition = player.Character.HumanoidRootPart.Position
11local cameraPosition = playerPosition + offset
12camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
13end
14 
15runService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, onRenderStep)
1script.Parent.Touched:Connect(function(hit)
2    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
3local NewCam = game.Players:GetPlayerFromCharacter(hit.Parent).StarterPlayer.StarterPlayerScripts:WaitForChild("CameraChange")
4 
5     NewCam.Disabled = false   
6end
0
did you change camera type to scripable? theking48989987 2147 — 6y
0
CurrentCamera is client side. User#19524 175 — 6y
0
Changing camera always needs to be client based. This means you'll have to add a LocalScript to the client(Player) and then access CurrentCamera from there to change the Camera's properties locally. Wutras 294 — 6y

Answer this question