I’ve made a 2D Camera Zone where the player’s camera change to a 2D sided view when touching an area (a block named camerapart in workspace)
Everything seems to work but It keeps that view even if the player is not longer touching that certain area. I tried the TouchEnded function but unfortunately I don’t know where to insert it and make it really work. I want the camera go back to normal when the player leaves that zone. Can you guys give me a little help?
Here’s the code:
-- define variables -- get local player local player = game.Players.LocalPlayer -- get the camera local camera = workspace.CurrentCamera -- get the part local part = game.Workspace.camerapart -- set debounce to false local isHit = false -- set up on touched function part.Touched:connect(function(hit) if not isHit then isHit = true -- see if it was hit by humanoid if hit.Parent:FindFirstChild("Humanoid") then -- check to see if it was hit by local player if hit.Parent.Name == player.Name then -- set camera cframe local camera = game.Workspace.CurrentCamera local player = game.Players.LocalPlayer camera.CameraType = Enum.CameraType.Scriptable local targetDistance = 30 local cameraDistance = -27 local cameraDirection = Vector3.new(-1,0,0) local currentTarget = cameraDirection*targetDistance local currentPosition = cameraDirection*cameraDistance game:GetService("RunService").RenderStepped:connect(function() local character = player.Character if character and character:FindFirstChild("Humanoid") and character:FindFirstChild("HumanoidRootPart") then local head = character.HumanoidRootPart camera.Focus = head.CFrame if head:FindFirstChild("FastStart") == nil then camera.CoordinateFrame = CFrame.new(Vector3.new(head.Position.X, head.Position.Y + 0, head.Position.Z - 0) + currentPosition, Vector3.new(head.Position.X, head.Position.Y, head.Position.Z - 0) + currentTarget) else --Lower camera for fast start camera.CoordinateFrame = CFrame.new(Vector3.new(head.Position.X, head.Position.Y - 0, head.Position.Z - 0) + currentPosition, Vector3.new(head.Position.X, head.Position.Y - 0, head.Position.Z - 0) + currentTarget) end end end) -- set camera back to normal but idk how yet lol game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid game.Workspace.CurrentCamera.CameraType = "Custom" wait() end end end wait(1) isHit = false end)