Camera Bug (Switching from scriptable back to custom)

Hey there,

I’ve spent a very long time trying to fix a bug relating to the camera, but everything I’ve tried is simply not working.

Basically the code works as follows:

  1. While the menu is visible, the camera is set to scriptable and it’s CFrame is set to a part.
  2. Once the player presses the “DEPLOY” button the players camera gets set to custom.

The issue here is, it only works once then it gets into this weird position. (Video of the bug is attached at the bottom.)

I’ve tried the following:

  • Manually setting the player’s camera CFrame to it’s head, that didn’t work sadly.

Here is the code:

local Player = game.Players.LocalPlayer
local StarterGui = game:GetService("StarterGui")
local Character = Player.Character

wait(0.01)
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = workspace:WaitForChild("CameraPart").CFrame
local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)

script.Parent.MouseButton1Click:Connect(function()
	if Player.Team == game.Teams.Loading then
		script.Parent.Parent.Parent.Parent.Parent.ActionUI:WaitForChild("message"):WaitForChild("WarningLabel").Visible = true
		wait(2.5)
		script.Parent.Parent.Parent.Parent.Parent.ActionUI:WaitForChild("message"):WaitForChild("WarningLabel").Visible = false
	elseif Player.Team == game.Teams.Republic then
		local StarterGui = game:GetService("StarterGui")
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
		game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("MorphPlayerEventRep"):FireServer(Player)
		script.Parent.Parent.Parent.Parent.Visible = false
		--StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
		script.Parent.Parent.Parent.Parent.Parent.ActionUI.Frame.people.Visible = true
		script.Parent.Parent.Parent.Parent.Parent.ActionUI.Frame.people2.Visible = true
		game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("SpawnPlayerEvent"):FireServer(Player)
		script.Parent.Parent.Parent.Parent.Visible = false
	elseif Player.Team == game.Teams.CIS then
		local StarterGui = game:GetService("StarterGui")
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		script.Parent.Parent.Parent.Parent.Parent.ActionUI.Visible = true
		StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
		game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("MorphPlayerEventCIS"):FireServer(Player)
		script.Parent.Parent.Parent.Parent.Parent.ActionUI.Frame.people.Visible = true
		script.Parent.Parent.Parent.Parent.Parent.ActionUI.Frame.people2.Visible = true
		--StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
		game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("SpawnPlayerEvent"):FireServer(Player)
		script.Parent.Parent.Parent.Parent.Visible = false 
	else
		warn("PLAYER IS NOT ON A TEAM YET!")
	end
end)

Thank you for your time.

1 Like

Sorry forgot to include the video. :skull:

Uploading it to YouTube now.

2 Likes

Here is the video of the bug: This bug is so annoying... wouldn't you agree... - YouTube

1 Like

If your curious:

I figured out the solution, I simply added a:
workspace.CurrentCamera.CameraSubject = Player.Character.Humanoid

That fixed it.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.