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

How to Manipulate Camera on an if statement?

Asked by 3 years ago

I'm not that sure what to title the Question but i'll explain.

So, I'm fairly new to creating Camera Manipulation. My goal was to manipulate the camera when the detector is enabled, and after 3s, will go back to the player.

I've placed the script in StarterPlayerScripts, and is a LocalScript.

The Outcome was that it did not work at all.

local detector = game.workspace.BlahBlah
local camera = game.workspace.CurrentCamera
local camerapart = game.workspace.CameraPart
local player = game.Player.LocalPlayer

if detector.Enabled == true then
    camera.CameraType = "Fixed"
    camera.Focus = camerapart.CFrame
    wait(3)
    camera.CameraType = "Custom"
    camera.CameraSubject = player.Character.Humanoid
end

1 answer

Log in to vote
0
Answered by 3 years ago

You could do:

detector:GetPropertyChangedSignal("Enabled"):Connect(function()
    if detector.Enabled == true then
        camera.CameraType = "Fixed"
        camera.Focus = camerapart.CFrame
        wait(3)
        camera.CameraType = "Custom"
        camera.CameraSubject = player.Character.Humanoid
    end
end)

:GetPropertyChangedSignal Detects when the detectors value is updated, and if it equals true, then it'll continue doing what you want.

0
at first didn't work but the problem was the player local so i placed it in the function. It worked but something off-topic is that the face of the camera keeps directing at the back djcraft1237 4 — 3y
0
Can you elaborate on what you mean by "directing at the back" DietCokeTastesGood 111 — 3y
Ad

Answer this question