Changing localcamera of vehicleseat occupant

Hey, so I have this script which is broken. What I want it to do is when a value is set to true, the camera of the person in the vehicleseat changes to what the “Fixed” position is. Like how the camera just locks into a position and cannot follow anything.

Below, I tried changing the currentcamera in workspace but I got lost and couldn’t figure out how to set it up. Any help would be appreciated.

while true do
    local funnyvalue = script.Parent.Parent.Parent.Values.TemporalDisplacement.Value
    local RunService = game:GetService("RunService")
    RunService.Heartbeat:Wait()
    if funnyvalue == true
    then
        workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
    else
        workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
    end

    end

Also this is the car I am working on, my idea is that the camera locks when the car disappears so you can see the time travel effect.

1 Like

Using a loop to detect a value change isn’t necessary, you can simply use .Changed or :GetPropertyChangedSignal

local funnyvalue = script.Parent.Parent.Parent.Values.TemporalDisplacement

funnyvalue:GetPropertyChangedSignal('Value'):Connect(function()
    if funnyvalue.Value == true then
        workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
        print('Scriptable')
    else
        workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
        print('Custom')
    end
end)
2 Likes

Alright, but how would I script the camera to be in the fixed position. I was told that if you were to do anything you would need to set it to Scriptable instead of Fixed.

1 Like

That’s correct, you would need to do that. An idea would be to add a new part which will be the place where the camera’s position will be set and set the camera’s CFrame to the part’s CFrame (if that makes sense)

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = Car.CameraPos.CFrame -- CameraPos = the part which the Camera will position at

Try it out and let me know if it works

1 Like

I get your idea, but I think it’s a problem with the script itself. It still isn’t updating the camera to the position of the attachment i set it to, and no errors show up in Output. I’m not sure it’s able to detect the localplayer in the vehicleseat and maybe that’s why it can’t change the camera, not sure

1 Like

Right now i have it at this, where it’s a localscript inside of a vehicleseat still. Was I supposed to put it somewhere else?

1 Like

Local scripts don’t run in workspace. If you want to change the camera, use a server script and fire an event to the client which will change it locally

1 Like

After setting the camera type to scriptable I would try doing this:

-- NOTE: This is untested and very much hypothetical. It isn't guaranteed to work.
local CameraCFrame = Camera.CFrame
Camera.Subject = nil
Camera.CFrame = CameraCFrame
1 Like

Where do I put the remoteevent? I want to put it in the model itself so that my model is easily compatible with my other games, but a tutorial is telling me to put it in the ReplicatedStorage

1 Like

Just move it to ReplicatedStorage. If you want to use the same model in different games, just drag the event into RS in that game, will work perfectly fine :+1:

1 Like

So how would I set this up exactly? Sorry if i’m bugging you, i’m more of a builder not a scripter