I've been trying to create a camera system in which I want the player to be unable to move while they are accessing the cameras. For some reason, it only works until you die and death disables the players movement until you access the cameras again for some reason which I don't understand. Can someone help? I've tried to create several failsafe's but they all don't work.
Here is the main pieces code - I removed some unimportant stuff which I know doesn't interfere with it:
local Plr = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
local FindPlayerGUI = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local UIS = game:GetService("UserInputService")
local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
_G.OpenedCams = false -- Global in case I need to use it in different script
-- Enable and Disable cams.
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.C then
if _G.OpenedCams == false then
_G.OpenedCams = true
print("Enter Cams")
FindPlayerGUI.CamsGUI.Enabled = true
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = workspace.DefaultCams:FindFirstChild("Cam"..script.Parent.CamID.Value).CameraPart.CFrame
controls:Disable()
elseif _G.OpenedCams == true then
_G.OpenedCams = false
print("Exit Cams")
FindPlayerGUI.CamsGUI.Enabled = false
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = Plr.Character.Humanoid
controls:Enable()
end
end
end)
