robloxapp-20220216-2041551.wmv (1.1 MB)
Hi! Today, we are going to make a security camera system! For this, you need :
-A bit of scripting
-Know something about cameras
-Little GUI knowledge
First, place a part :
You can make a camara model to it, but for the camera system, place a part. Call it Test1 for now.
After that, make a trigger part. The trigger methods can be proximity prompts, clickdetectors, touch events, you can make it.
Trigger part :
I called it “Camera2TriggerPart”
You can make designs to the cam system.
Now, make the part what ppl can see when activated the system.
I called it Test7, since this is my last cam.
-Gui
For now, we’ll create the gui.
Make a ScreenGui inside of StarterGui, and make the buttons inside of the camera buttons :
We need 1 button for each camera, and an off button (we will close the system with that).
Create a LocalScript, and put this inside of it :
script.Parent.MouseButton1Up:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = game.Workspace.Test1.CFrame --Change the part's name
end)
You can control clone and copy it into the another buttons, but change the camera part name.
Inside of our close aka off button, put this :
script.Parent.MouseButton1Up:Connect(function()
game.Workspace.Camera.CameraType = Enum.CameraType.Custom
script.Parent.Parent.Enabled = false
end)
After this, make this ScreenGui’s enabled false.
As I mentioned, you need to know cams. The reason why is because they are camera types. The custom is what good for players, they can do whatever they want. Back to the camera buttons, we said “Enum.CameraType.Scriptable”, because if it’s scriptable, we can script over it.
-Scripting
Go to the trigger part, create a proximity prompt / clickdetector.
Inside of StarterGui, create a LocalScript.
Put this inside of it :
local player = game:GetService("Players").LocalPlayer
local Popup = workspace.Camera2TriggerPart --Our TriggerPart
Popup.ProximityPrompt.Triggered:Connect(function() --If the ProximityPrompt is triggered then
script.Parent.InsertedObjects.Enabled = true --We enable the ScreenGui where the camera buttons are
game.Workspace.Camera.CameraType = Enum.CameraType.Scriptable --Scriptable cameratype (!)
game.Workspace.Camera.CFrame = game.Workspace.Test7.CFrame --We set our camera's cframe to the starter camera system part
player.Character.Humanoid.WalkSpeed = 0 --We set them, so they can't jump or move
player.Character.Humanoid.JumpPower = 0
script.Parent.InsertedObjects.power.MouseButton1Up:Connect(function() -- If they click on the close button then
player.Character.Humanoid.WalkSpeed = 16 --They can run again
player.Character.Humanoid.JumpPower = 16 --They can jump again
end)
end) --We disabled the gui in the close button's script
game.Workspace.Camera.CameraType = Enum.CameraType.Scriptable
game.Workspace.Camera.CFrame = game.Workspace.Test7.CFrame
The whole meanings of this tutorial was these 2 lines, because this is how you can manipulate someone’s camera. You can tween the camera too.
–Tweening camera :
local function tween(part1, part2)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part1.CFrame
local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
tween:Play()
wait()
end
–Tweening the Field Of View
local function propertytween(part1,first,second)
local TweenService = game:GetService("TweenService")
local part = part1
part.FieldOfView = first
local goal = {}
goal.FieldOfView = second
local tweenInfo = TweenInfo.new(1.5)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
end
Thank you if you finished the reading! Hope it was helpfull and a good tutorial. Bye!