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

Why will Enum.CameraType.Custom not connect the camera back the player after the script is ran?

I am currently working on making a GUI reappear when a player dies and it works perfectly the first time. The second time it works fine except when I tell it to return the camera type to custom, it does make it custom but the camera isn't connected to the player. Any ideas?

Example of what I'm talking about

Script:

game.ReplicatedStorage.RemoteEvents.PlayButton.OnClientEvent:Connect(function()

local backpack = game.Players.LocalPlayer.Backpack

		local looky = game.Workspace.CurrentCamera
	
		if backpack:FindFirstChild("Holy Lightning Blade") then
		
		storage.RemoteEvents.MobileOn:FireServer()
		
		script.Parent.Visible = false
		
		repeat wait()
		looky.CameraType = Enum.CameraType.Custom
		until looky.CameraType == Enum.CameraType.Custom
		
			elseif backpack:FindFirstChild("Metal Blade") then
		
			storage.RemoteEvents.MobileOn:FireServer()
		
			script.Parent.Visible = false
		
			repeat wait()
			looky.CameraType = Enum.CameraType.Custom
			until looky.CameraType == Enum.CameraType.Custom
			
				elseif backpack:FindFirstChild("Starter Blade") then
			
				storage.RemoteEvents.MobileOn:FireServer()
			
				script.Parent.Visible = false
			
				repeat wait()
				looky.CameraType = Enum.CameraType.Custom
				until looky.CameraType == Enum.CameraType.Custom
				
					elseif backpack:FindFirstChild("Starter Sword") then
			
					storage.RemoteEvents.MobileOn:FireServer()
			
					script.Parent.Visible = false
			
					repeat wait()
					looky.CameraType = Enum.CameraType.Custom
					until looky.CameraType == Enum.CameraType.Custom
					
						elseif backpack:FindFirstChild("Steel Sword") then
			
						storage.RemoteEvents.MobileOn:FireServer()
					
						script.Parent.Visible = false
					
						repeat wait()
						looky.CameraType = Enum.CameraType.Custom
						until looky.CameraType == Enum.CameraType.Custom
						
								elseif backpack:FindFirstChild("Sword") then
				
								storage.RemoteEvents.MobileOn:FireServer()
							
								script.Parent.Visible = false
							
								repeat wait()
								looky.CameraType = Enum.CameraType.Custom
								until looky.CameraType == Enum.CameraType.Custom
								
									elseif backpack:FindFirstChild("Sword Of Light") then
				
									storage.RemoteEvents.MobileOn:FireServer()
									
									script.Parent.Visible = false
									
									repeat wait()
									looky.CameraType = Enum.CameraType.Custom
									until looky.CameraType == Enum.CameraType.Custom
									
										elseif backpack:FindFirstChild("Wooden Sword") then
			
										storage.RemoteEvents.MobileOn:FireServer()
									
										script.Parent.Visible = false
									
										repeat wait()
										looky.CameraType = Enum.CameraType.Custom
										until looky.CameraType == Enum.CameraType.Custom
		
			else
				script.Parent.Parent.NoSword.Position = UDim2.new(0.321, 0,0.321, 0)
		end
end)

(The script broke when I pasted it)

3 comments

0

I don't see where you're setting the camera type back to the default one for it to lock onto the character

0

Look inside one of the elseif blocks, it should be towards the end where it says repeat wait()

0

I couldn't remember if Roblox used Custom or a different camera type for attaching to the player. Set the CameraSubject to the player's humanoid in their character

1 answer

Thank you MrLonely1221. I solved this by adding a block that changes the camera's subject to the player's humanoid.

repeat wait()
looky.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
until looky.CameraSubject == game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

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