Camera.Custom doesn't work properly?

Hey,

I made a loading screen but once you click play the camera doesn’t reset properly, but only sometimes. Sometimes it works perfectly and sometimes it doesn’t.

Here is the code:

script.Parent.MouseButton1Click:Connect(function()
	cam.CameraType = Enum.CameraType.Custom
	
	script.Parent.Parent.Enabled = false
end)

Video of the issue:
https://gyazo.com/9efc58d5593bfb361472e70c6f2173e7

I can somehow move my camera freely and control my character but its stuck in the air

2 Likes

This happened to me a while ago, i fixed it by instead of using Enum.CameraType.Custom i put CameraType = “Custom”

1 Like

How would the line look like?
cam.CameraType = Enum.CameraType.Custom
Because there is already a “=”

like this
cam.CameraType = “Custom”

1 Like

image

the devforum’s “ don’t work with copy paste just delete them and write it yourself

1 Like

It worked a couple times but then it broke as well.
But maybe a different script is the reason for that. I have a script which automatically resets the player when joining, while he is in the scriptable camera mode. Maybe this breaks it?

It could be the other script, put the cameratype line in the other script and test

Don’t think that will work because the camera should only reset once the player clicks play.

local TeamChecker = script.Parent

local event = game:GetService("ReplicatedStorage").RemoteEvent


TeamChecker.Touched:Connect(function(hit)

		if hit.Parent:FindFirstChild("Humanoid") then
		print("touched works")
		
			local Tycoons = game.Workspace:WaitForChild("Zednov's Tycoon Kit"):WaitForChild("Tycoons") 
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		game:GetService("BadgeService"):AwardBadge(player.UserId, 2125663262)
		for _,child in pairs(Tycoons:GetChildren()) do
			print("before found")
			if player.Team == game.Teams[child.Name] then
					print("child found")

					--player.TeamColor = child.TeamColor.Value
					--child.Owner.Value = player
					player.RespawnLocation = child.Essentials.Spawn
					player:LoadCharacter()
					print("before break")
				break
			
				end
			end
			wait(0.1)
		end
	end)

Thats the other script

What else sets the Camera type in your game?

This sort of issue usually occurs due to execution times, for example, you have a script that rotates the camera around an area, like a cutscene, however that cutscene is technically still running when you’re trying to reset the camera.

Also, always try to use the correct Class Type (CameraType is an Enum , not a string).

Yes the camera is rotating. Do you think that’s the issue?

local Cam = game.Workspace.Camera
local introCam = game.Workspace.Cam

repeat wait() until Cam.CameraSubject ~= nil
Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = introCam.CFrame

while Cam.CameraType == Enum.CameraType.Scriptable do
	local x, y, z = Cam.CFrame:ToOrientation()
	local Rot = y + math.rad(wait()*4)
	if math.deg(Rot) >= 360 then Rot = 0 end
	Cam.CFrame = CFrame.fromOrientation(x, Rot, z) + Cam.CFrame.Position
end

StarterPlayerScripts

What do you mean by that? How should it look like?

It’s the exact same thing. “Custom” is automatically converted to Enum.CameraType.Custom.


Try setting Camera.CameraSubject to the player’s Humanoid.

1 Like

How would I do that and whats the use of that?

script.Parent.MouseButton1Click:Connect(function()
    cam.CameraType = Enum.CameraType.Custom
	
    cam.CameraSubject = game:GetService("Players").LocalPlayer.Character.Humanoid

    script.Parent.Parent.Enabled = false
end)

Assuming it’s a localscript.

Maybe the camera’s controller is getting set to the default one (“Custom”), but since there’s no subject it isn’t following anything.

Also, this is a localscript, right?

1 Like

Yes it is. Thanks I will try it.

Yes, ensure that your rotation Script is stopped before resetting the camera.

As for what I meant by class type, others have suggested this.

cam.CameraType = “Custom”

However, CameraType is not a String (text), but an Enum.

cam.CameraType = Enum.CameraType.Custom

It is good coding practice to always use the correct type, and will be more performance as the system doesn’t have to try to convert the string to Enum for you.
You can also clearly see the different types of values with intelisense.

1 Like

I sent the rotation script, do you think it is the cause of the problem? Or is it fine?

I tried this script but it broke it. Now nothing is happening when i click Play.

Players.ByGoalZ.PlayerGui.Play.TextButton.LocalScript:2: attempt to index nil with ‘CameraType’

image