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

How do I properly set Current Camera to a given object?

Asked by 3 years ago

I feel silly writing this, but I just cannot seem to understand why this local script won't work. The intention of the script is just to set the camera of the local player to a given object (farm_camera) once the player joins. However, the camera is set to somewhere on the ground instead of up in the air, as I've instructed it to, which I cannot seem to understand. The script is a local script and is located in StarterPlayerScripts, there are no error messages, and it seems to have worked before, but without changing it, it stopped working.

local camera = workspace.CurrentCamera
local plr = game.Players.LocalPlayer

local farm_camera = workspace:WaitForChild("Farm_Camera")

camera.CameraType = Enum.CameraType.Fixed
camera.CameraSubject = farm_camera

I wouldn't call myself an amateur, nor am I too new to scripting, so my ego tells me the problem cannot be that simple (yet it probably is) Anyhow, thnx for helping!

1 answer

Log in to vote
0
Answered by 3 years ago

local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Camera = workspace.CurrentCamera repeat wait() Camera.CameraType = Enum.CameraType.Scriptable until Camera.CameraType == Enum.CameraType.Scriptable Camera.CFrame = workspace.C_view.CFrame -- C_view is the name of your camera, and make sure the front surface is facing where you want it to be.

To get this one to work you just put a local script in a GUI and use this code. If this isn't what you want then my apologies. Also, you said it worked before, is the part anchored?

0
Ty, it worked just as intended, I still don't understand what was wrong with my script, and why it worked before, but not now. Anyways, thank you. ROOBLOXJakob123 22 — 3y
0
No worries, and no problem. Iroxxigar 24 — 3y
Ad

Answer this question