How would I make sure that the camera attaches to the player?

Obligatory its midnight and I am tired, so if I make no sense then you know why. Also might be a bit long for me to reply as I am gonna go to sleep. Anyways no more excuses

Not really sure what to say here, the camera won’t attach to the player, so output errors, and its set at custom camera, not anything else. Script is, I dont know its something so ill highlight the important stuff

localscript inside a gui (under a textbutton), highlighted lines that i think have the problem:


if workspace.isround.Value == true then
		script.Parent.Text = "Loading. . ."
		for i = 1, 0, -.02 do
			script.Parent.Parent.Parent.darkness.BackgroundTransparency = i
			wait()
		end
		script.Parent.Parent.Parent.darkness.BackgroundTransparency = 0
		wait(.5)
		repeat wait()
			Camera.CameraType = Enum.CameraType.Custom
		until Camera.CameraType == Enum.CameraType.Custom
		script.Parent.Parent.Parent.dead.Visible = true
		script.Parent.Parent.Visible = false
		script.Parent.Parent.Parent.dead.LocalScript.Disabled = true
		script.Parent.Parent.Parent.dead.LocalScript.Disabled = false
		wait(.5)
		for i = 0, 1, .02 do
			script.Parent.Parent.Parent.darkness.BackgroundTransparency = i
			wait()
		end
		script.Parent.Parent.Parent.darkness.BackgroundTransparency = 1

localscript inside a gui (under a textbutton) (whole script)


disabled = false
local Camera = workspace.CurrentCamera
script.Parent.MouseButton1Click:Connect(function()
	--[[]if disabled == false then
		disabled = true
		script.Parent.BackgroundColor3 = Color3.new(217, 0, 0)
		game.Workspace.Teleport.RemoteFunction:InvokeServer()
		wait()
		disabled = false
		
		game.Players.LocalPlayer.PlayerGui.CameraGui.lol.Visible = false
		game.Players.LocalPlayer.PlayerGui.CameraGui.Container.Visible = false
		
	end]]
	if workspace.isround.Value == true then
		script.Parent.Text = "Loading. . ."
		for i = 1, 0, -.02 do
			script.Parent.Parent.Parent.darkness.BackgroundTransparency = i
			wait()
		end
		script.Parent.Parent.Parent.darkness.BackgroundTransparency = 0
		wait(.5)
		repeat wait()
			Camera.CameraType = Enum.CameraType.Custom
		until Camera.CameraType == Enum.CameraType.Custom
		script.Parent.Parent.Parent.dead.Visible = true
		script.Parent.Parent.Visible = false
		script.Parent.Parent.Parent.dead.LocalScript.Disabled = true
		script.Parent.Parent.Parent.dead.LocalScript.Disabled = false
		wait(.5)
		for i = 0, 1, .02 do
			script.Parent.Parent.Parent.darkness.BackgroundTransparency = i
			wait()
		end
		script.Parent.Parent.Parent.darkness.BackgroundTransparency = 1

		
		
		game.Workspace.Teleport.RemoteFunction:InvokeServer()
		script.Parent.Parent.Parent.lol.Visible = false
		print("its true")
	elseif workspace.isround.Value == false then
		print("its false")
		
		local object = script.Parent.Parent.Parent.none
		object.AnchorPoint = Vector2.new(0.5, 0.5)
		object.Position = UDim2.new(0.1, 0, 0.5, 0)

		wait(1)
		script.Parent.Parent.Parent.none.Visible = true
		script.Parent.Parent.Parent.lol.Visible = false
		object:TweenPosition(UDim2.new(0.5, 0, 0.5, 0))
		wait(2)
		object:TweenPosition(UDim2.new(-0.5, 0, -0.5, 0))
		script.Parent.Parent.Parent.lol.Visible = true
	end
	
end)

any ideas on how to shorten it would be great, but not the priority

Ok maybe let us know what you see in the console output.
Also is the script.Parent.Text changing to “Loading. . .”?
And is the darkness Background changing?

yes, i will check the console output but everything is working, its like the script completely misses the camera change

no output errors, or console output

Are you saying that the repeat wait for the cameratype change does not run?

i think so, the camera type does change from scriptable (another script) to custom, but it orbits a random spot everytime, its not attached, ive attached an image

to the player

Hey, do you mean lock the camera into the player’s position?

yea, you know when you join a game, the camera is locked onto the player (not trying to be passive agressive)

Wait, do you mean locked in first person?

no like the orbital around the player, 3rd person if you will

So it’s locked in third person. Right?

1 Like

All you have to do is click starter player:
image
Click the minimum zoom distance and set it to 128. There’s no scripting required for lock in first person or third person.

ok, my bad but I have like a little intro I set up, where when a player enters the game the camera is set to scriptable so it won’t move, I then need for the camera to be back set to custom or the orbital one so then the game is playable. Right now the camera is stuck a few feet behind the player (see photo below) while it can orbit, it orbits around a random point and does not follow the players movement in any way

Sorry for the misunderstanding

That’s all fine and I understand this is a difficult concept to explain especially when you were tired and it was night.

workspace.Camera.CameraType = Enum.CameraType.Scriptable
-- your code here --
workspace.Camera.CameraType = Enum.CameraType.Custom

Thanks, I already have a line

repeat wait()
			Camera.CameraType = Enum.CameraType.Custom
		until Camera.CameraType == Enum.CameraType.Custom

Wait, I don’t understand the point of the loop if your loop will break when the camera type is set to custom and your setting it to custom with no other code in it in the loop.

I stole it from another loop to make sure that the camera was being set to custom, heres that loop if you’re curios

repeat wait()
	Camera.CameraType = Enum.CameraType.Scriptable
	until Camera.CameraType == Enum.CameraType.Scriptable
	Camera.CFrame = workspace.CameraPart.CFrame

I think the problem might be in the gui. A gui doesn’t allow you to move your camera while your on the gui so a glitch might have happened while doing that and made the camera state hang(more specifically the state of the camera is unable to be changed because of the gui).

Ok, how would I fix that? Is it something that can be fixed?

Well, I’ve thought of adding a wait after changing the gui. That might be a good idea.

Ok, would I just add a wait(1) or wait() before the line that changes it?