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.

local offset = Vector3.new(50,10,0)
local fieldOfView = 100
local player = script.Parent.Parent
local camera = game.Workspace.CurrentCamera
local runService = game:GetService("RunService")

camera.FieldOfView = fieldOfView
local function onRenderStep()

local playerPosition = player.Character.HumanoidRootPart.Position
local cameraPosition = playerPosition + offset
camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
end

runService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, onRenderStep)
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
local NewCam = game.Players:GetPlayerFromCharacter(hit.Parent).StarterPlayer.StarterPlayerScripts:WaitForChild("CameraChange")

     NewCam.Disabled = false    
end
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