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)

2 comments
I don't know why you would want a player to still be able to use something when realistically they are dead. But try using a .Touched event instead?
No I meant like after they die, when they sit down on the seat nothing happens