I am working on a security camera system, however when a player resets or gets killed and sits on the chair again, the stuff that's supposed to happen when a player sits on the seat does not. Why is that happening? I put the script in StarterPlayerScripts by the way.
Local Script:
camera = workspace.CurrentCamera player = game.Players.LocalPlayer character = player.Character or player.CharacterAdded:Wait() humanoid = character:WaitForChild("Humanoid") securityCams = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Security") remotes = game.ReplicatedStorage.Remotes humanoid.Seated:Connect(function(seated, seat) if seated then securityCams.Open.Visible = true else for _, element in pairs(securityCams:GetChildren()) do element.Visible = false end repeat wait() camera.CameraType = Enum.CameraType.Custom until camera.CameraType == Enum.CameraType.Custom end remotes.DisableSecurity.OnClientEvent:Connect(function() for _, element in pairs(securityCams:GetChildren()) do element.Visible = false end repeat wait() camera.CameraType = Enum.CameraType.Custom until camera.CameraType == Enum.CameraType.Custom end) end)
Hey, I'm late on this, but for all the future people who see this:
The answer is because when you die, your humanoid is deleted and a new one replaces it. Therefore, all connections related to humanoid are destroyed. Every time a new character is added, you have to redefine that connection.