I’m trying to make a game that has a camera that stays something like this
The thing is though that I’m not very good at scripting (T-T) but I did find some guides on how to do it.
It worked before, but now it doesn’t when i try testing the game. Does anyone know how to fix it?
local CurrentCamera = game.Workspace.CurrentCamera
CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = CFrame.new(-28, 8.36, -22.053) * CFrame.Angles(math.rad(5), math.rad(180), 0)
CurrentCamera.FieldOfView = 50
2 Likes
It’s in a LocalScript in StarterPlayerScripts
1 Like
The default camera scripts are probably overwriting the CameraType
. They’re supposed to not update the camera when its set to Scriptable
type, but this might not be guaranteed if you set the CameraType
before the default scripts load.
I would suggest putting this script in StarterPlayerCharacter
too
There is a Test tab which lets you start a local game server with local clients connected to it which helps simulate things like latency, but it takes a few seconds to start up which is impractical for when you are rapidly testing something.
1 Like
Studio is down rn but could we get more context? The code you used looks fine to me, maybe something else in the script is bugging with it
Unless thats your entire script
1 Like
Ah wait I think I know what it is. Try
game.Workspace:WaitForChild("CurrentCamera")
instead of game.Workspace.CurrentCamera
The script is loading in before the camera does which makes it work improperly. Always use WaitForChild for values that load in once a server/client is opened
1 Like
Oh studio isn’t saving for you too?
That’s my entire script, so I don’t really know what could be causing this not to work.
Like sometimes it does but then also sometimes it doesn’t.
this is what it’s like when it’s working
1 Like
You probably need to click Publish to Roblox
not Save
.
Try waiting for the character to load before setting the camera.
workspace.CurrentCamera
is a property, so you can not use WaitForChild
(This is a scenario where Roblox engineers wish they did not use .
for child members and property members!). Additionally it is guaranteed the camera exists even if the LocalScript runs in ReplicatedFirst
1 Like
I tried adding it, but it’s not working
1 Like
Yep I knew it. Script is loading in before the camera does
Scripts tend to load in before any physical objects. any time you have values at the start of your script, use :WaitForChild()

You can also try repeat task.wait() until game:IsLoaded()
at the start of your script
1 Like
Roblox is currently down, thats why no saves are going through
so like this?
local camera = game.Workspace:WaitForChild(“CurrentCamera”)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(-28, 8.36, -22.053) * CFrame.fromEulerAngles(math.rad(5), math.rad(180), 0)
camera.FieldOfView = 50
repeat task.wait() until game:IsLoaded()
1 Like
The repeat would go at the start of the scripts, vefore the values
1 Like
repeat task.wait(3) until game:IsLoaded()
local camera = game.Workspace:WaitForChild(“CurrentCamera”)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(-28, 8.36, -22.053) * CFrame.fromEulerAngles(math.rad(5), math.rad(180), 0)
camera.FieldOfView = 50
I’m testing it out, but it still isn’t working
1 Like
Question, why are you using “CurrentCamera”? Shouldnt it just be “Camera”? There’s no reason to have 2 different cameras
Game.IsLoaded
is a property. Also your script is in StarterPlayerScripts
so it is not ran until the game has loaded, so you do not need to do that.
Just wait for the player’s character to exist.
2 Likes
workspace.CurrentCamera
is a property that refers to the current Camera
instance that is being used to position the view model.
2 Likes
Try just using “camera”, it should work fine, unles theres something wrong with that
1 Like
Hi! I tried using your script but it didn’t work at first either. After taking a closer look, I made a few modifications to make it functional again. Here’s a working version that you can use:
Just insert this script inside a LocalScript under StarterPlayer > StarterPlayerScripts:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local function Camera()
local CurrentCamera = workspace.CurrentCamera
CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = CFrame.new(-28, 8.36, -22.053) * CFrame.Angles(math.rad(5), math.rad(180), 0)
CurrentCamera.FieldOfView = 50
end
task.wait(2)
Camera()
4 Likes
I dont think the task.wait() is necessary, I typically dont like using set numbers when waiting for things to load since client load times can vary, but ya try that!!
1 Like
omg I think this one works!
If I were to like leave the room and change the camera perspective to a hallway, would that work too?
2 Likes