Why doesn't thing work 100% through FilteringEnabled? This is in a LocalScript located in the PlayerGui. Sometimes whenever the player resets, the script doesn't work. Some variables have been removed

repeat wait() until game:GetService("Players").LocalPlayer.Character

local Player = game:GetService("Players").LocalPlayer
local Playing = Player:WaitForChild("Playing")
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
local CurrentCamera = workspace.CurrentCamera
CurrentCamera.CameraType = Enum.CameraType.Custom
CurrentCamera.CameraSubject = Humanoid

while wait() do
	if Timer.Value > 0 and Playing.Value == false and Humanoid and Humanoid.Health > 0 and Database.Visible == false then
		CurrentCamera.CameraType = Enum.CameraType.Scriptable
		local Target = MapHolder:FindFirstChild(SelectedMap.Value):FindFirstChild("PartCAM")
		CurrentCamera.CameraSubject = Target
		CurrentCamera.CoordinateFrame = CFrame.new(Target.Position) * CFrame.Angles(math.rad(Target.Rotation.X), math.rad(Target.Rotation.Y), math.rad(Target.Rotation.Z))
	elseif Timer.Value < 0 or Database.Visible == true and Playing.Value == false and Humanoid and Humanoid.Health > 0 then
		CurrentCamera.CameraType = Enum.CameraType.Scriptable
		local Target = workspace.Scene:FindFirstChild("PartCAM")
		CurrentCamera.CameraSubject = Target
		CurrentCamera.CoordinateFrame = CFrame.new(Target.Position) * CFrame.Angles(math.rad(Target.Rotation.X), math.rad(Target.Rotation.Y), math.rad(Target.Rotation.Z))
	elseif Timer.Value > 0 and Playing.Value == true and Humanoid and Humanoid.Health > 0 then
		CurrentCamera.CameraType = Enum.CameraType.Custom
		CurrentCamera.CameraSubject = Humanoid
	end
end

2 comments

0

Put a print function before and after lines that contain WaitForChild and see if some of the prints don't execute.

0

It always prints.