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)
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")