Camera activates when pressed a key on a keyboard Tutorial! [Roblox Studio]

Опубликовано: 16 Июль 2026
на канале: Uhm
214
4

Hello everyone! This is my first tutorial video so don't judge on how bad is it/

Here's the script:

local UIS = game:GetService("UserInputService")--UserInputService
local camera = workspace.CurrentCamera -- Player camera
local target1 = workspace:WaitForChild("Camera1") -- Change it to your First Camera
local target2 = workspace:WaitForChild("Camera2") -- Change it to your Second Camera
local db = false

UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.G then -- Change to your key
if db == false then
script.Parent.Enabled = true -- Screen gui enabled
camera.CameraType = Enum.CameraType.Scriptable -- Camera type
camera.CFrame = workspace.Camera1.CFrame -- Camera CFrame
db = true
else
db = false
script.Parent.Enabled = false -- Screen gui disabled
camera.CameraType = Enum.CameraType.Custom
end
end
end)

script.Parent.Second.MouseButton1Click:Connect(function() -- Second button pressed
camera.CFrame = target2.CFrame
end)
script.Parent.First.MouseButton1Click:Connect(function() -- First button pressed
camera.CFrame = target1.CFrame
end)