Camera GUI only works in Studio

Hi!
I have this CameraGUI that only works in Studio. What am I doing wrong?
Studio:


ROBLOX:

print "camera"
local camera = workspace.CurrentCamera

local cameraPart = workspace:WaitForChild("campart1") -- Add The Camera Part There

repeat wait()

	camera.CameraType = Enum.CameraType.Scriptable

until camera.CameraType == Enum.CameraType.Scriptable

camera.CFrame = cameraPart.CFrame
print "done"

NOTE: prints are for making sure it’s running.

4 Likes

Could this be because of loading time?

No. I dont know what is causing it because it works in Studio.

I noticed that there is a little dev beta in the corner, are you using the same game or do you have 2 games? one for testing and one for the actual playing

It could also be that somebody is occupying the current camera so maybe be more implicit by just doing workspace.Camera from a local script instead

No, that’s the real game. I just have that there. I dont know why it’s broken really.

Like when Roblox takes time to load the game when you join a server.

Will this revive the topic? Still not solved.

This is based on game loading times. You have to wait until the Camera locks onto the player, as it is ran after this script is occurring.

Try adding

repeat wait()
until game:IsLoaded()

In the beginning.

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

Would that break the solution? It’s in my Loading GUI.

I don’t think so since i dont think the loading gui decides if the game is loaded or not.


Still nothing. Only change is the hot new avatar :wink:

Could you specify where is the script located in the explorer?

image

Try moving it to the StarterPlayerScripts folder.

The entire UI? I only want that appearing with that specific frame.

No, only move the camera script.

That would mean it would stay even if the UI is closed?

Well you can disable it when the frame is closed.

`local camscript1 = StarterPlayer.StarterCharacterScripts.CamScript1

btn.MouseButton1Click:Connect(function()

camscript1.Disabled = true

end)

WOuld this fix it?