Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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?

2 comments

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.

0

No worries, and no problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.