Skip to main content

API

The API allows you to control parts of the Camera System with your own scripts.

To use the API in your scripts, use this code:

local api = require(workspace.CameraSystem:WaitForChild("Api"))

There are 3 types of APIs: shared, server-only and client-only. Shared methods can be accessed in both local scripts and normal scripts. Server-only methods can only be accessed from server (normal) scripts and client-only methods can only be accessed from local scripts.

Shared

Methods

GetCamsById()

Returns all cameras, indexed by their IDs. This method returns a table with 4 elements:

  • Default, which is the CFrame of the default camera
  • Drones, which is a table of all drone models
  • Moving, which is a table of all moving camera models
  • Static, which is a table of all static camera models
local cameras = api:GetCamsById()
print(cameras)
--[[
{
Default: CFrame,
Drones: { Part },
Moving: { Model },
Static: { Part }
}
]]

GetCamIdByName()

Returns the ID of a camera with the given type and name

local camId = api:GetCamIdByName("Static", "TestCamera")
print(camId) -- 1

GetCamById()

Returns the camera model (or part) for the given camera

local cameraPart = api:GetCamById("Static", 1)
print(cameraPart) -- <Part>

GetDefaultCamPosition()

Returns the CFrame of the default camera

local cframe = api:GetDefaultCamPosition()
print(cframe) -- 34.496788, 1.00002861, 15.5882168, 0, ...

Server-only

Methods

ChangeCam()

Changes the current camera to the given camera. You need to provide the type of camera and its name or id

api:ChangeCam("Static", "CameraTest")
-- or
api:ChangeCam("Static", 1)

GetCurrentCamera()

Returns basic information about the currently active camera

local currentCamera = api:GetCurrentCamera()
print(currentCamera)
--[[
{
Id = <number>,
Model = <Model>,
Type = "Static" or "Moving" or "Drones"
}
]]

Focus()

Allows you to change what the cameras are focused on. You can provide a part, a username or nil.

api:Focus(workspace.Part)
api:Focus("gabys2005")
api:Focus(nil) -- unfocuses

GetFocus()

Returns what the camera currently focuses on

local focus = api:GetFocus()
print(focus)
--[[
{
Type = "Player",
Instance = HumanoidRootPart
}
OR
{
Type = "Part",
Instance = <Part>
}
]]

ChangeFov()

Changes the FOV over the specified amount of time. By default the time is 0.1 seconds

api:ChangeFov(120) -- change FOV to 120 over 0.1 seconds
api:ChangeFov(30, 5) -- change FOV to 30 over 5 seconds

ChangeAutoFov()

Turn auto FOV on or off

api:ChangeAutoFov(true) -- enable
api:ChangeAutoFov(false) -- disable

ChangeSmoothFocus()

Turn smooth focus on or off

api:ChangeSmoothFocus(true) -- enable
api:ChangeSmoothFocus(false) -- disable

ChangeBlur()

Allows you to change the blur over some time. By default the time is 0.1 seconds

api:ChangeBlur(20) -- change blur to 20 over 0.1 seconds
api:ChangeBlur(0, 5) -- change blur to 0 over 5 seconds

ChangeSaturation()

Allows you to change the saturation over some time. By default the time is 0.1 seconds

api:ChangeSaturation(-1) -- change the saturation to -1 over 0.1 seconds
api:ChangeSaturation(1, 3) -- change the saturation to 1 over 3 seconds

ChangeTilt()

Allows you to change the tilt over some time. By default the time is 0.1 seconds

api:ChangeTilt(45) -- change the tilt to 45 over 0.1 seconds
api:ChangeTilt(-45, 6) -- change the tilt to -45 over 6 seconds

ChangeBlackout()

Allows you to enable, disable or toggle the blackout

api:ChangeBlackout(true) -- enable
api:ChangeBlackout(false) -- disable
api:ChangeBlackout() -- toggle

ChangeBarsEnabled()

Allows you to enable, disable or toggle the bars

api:ChangeBarsEnabled(true) -- enable
api:ChangeBarsEnabled(false) -- disable
api:ChangeBarsEnabled() -- toggle

ChangeBarSize()

Changes the size of the size over some time. The size is a percentage of the screen height, so 50% will cover the entire screen and 25% will cover half of the screen.

api:ChangeBarSize(10) -- change bar size to 10% over 0.1 seconds
api:ChangeBarSize(30, 5) -- change bar size to 30% over 5 seconds

ChangeTransition()

Change the transition type. Possible types are None, Black and White

api:ChangeTransition("Black")

ChangeTransitionSpeed()

Change the transition speed. The speed you provide is the percentage of the base time, so 50 means 50% of the base time and will make the transition happen in half the time

api:ChangeTransitionSpeed(50)

ChangeShake()

Changes the shake intensity

api:ChangeShake(5)

GetFov()

Returns the current FOV

print(api:GetFov()) -- { Value = 70, Time = 0.1 }

GetBlur()

Returns the current blur

print(api:GetBlur()) -- { Value = 0, Time = 0.1 }

GetSaturation()

Returns the current saturation

print(api:GetSaturation()) -- { Value = 0, Time = 0.1 }

GetTilt()

Returns the current tilt

print(api:GetTilt()) -- { Value = 0, Time = 0.1 }

GetBarsEnabled()

Returns a boolean indicating whether or not the bars are enabled

print(api:GetBarsEnabled()) -- false

GetBarSize()

Returns the current bar size

print(api:GetBarSize()) -- 20

GetTransition()

Returns the current transition's name

print(api:GetTransition()) -- "Black"

GetTransitionspeed()

Returns the current transition speed

print(api:GetTransitionSpeed()) -- 100

GetShake()

Returns the current shake intensity

print(api:GetShake()) -- 0

Events

CameraChanged

Fired when the camera changes

api.CameraChanged:Connect(function(camType, camId)
print("Camera changed to a " .. camType .. " camera with an id of " .. camId)
end)

FocusChanged

Fired when the focus changes

api.FocusChanged:Connect(function(focusData)
print("Focus changed:", focusData)
end)

FovChanged

Fired when the fov changes

api.FovChanged:Connect(function(newFov, changeTime)
print("Fov changed to:", newFov, "in", changeTime, "seconds")
end)

BlurChanged

Fired when the blur changes

api.BlurChanged:Connect(function(newBlur, changeTime)
print("Blur changed to:", newBlur, "in", changeTime, "seconds")
end)

SaturationChanged

Fired when the saturation changes

api.SaturationChanged:Connect(function(newSaturation, changeTime)
print("Saturation changed to:", newSaturation, "in", changeTime, "seconds")
end)

TiltChanged

Fired when the tilt changes

api.TiltChanged:Connect(function(newTilt, changeTime)
print("Tilt changed to:", newTilt, "in", changeTime, "seconds")
end)

BlackoutChanged

Fired when the blackout changes

api.BlackoutChanged:Connect(function(isEnabled)
print("Blackout is now", if isEnabled then "Enabled" else "Disabled")
end)

BarsEnabledChanged

Fired when the bars get enabled or disabled

api.BarsEnabledChanged:Connect(function(isEnabled)
print("Bars are now", if isEnabled then "Enabled" else "Disabled")
end)

BarSizeChanged

Fired when the bar size changes

api.BarSizeChanged:Connect(function(newSize, changeTime)
print("Bar size changed to:", newSize, "in", changeTime, "seconds")
end)

TransitionChanged

Fired when the transition type changes

api.TransitionChanged:Connect(function(transitionName)
print("Bar size changed to:", transitionName)
end)

TransitionSpeedChanged

Fired when the transition speed changes

api.TransitionSpeedChanged:Connect(function(newSpeed)
print("Transition speed changed to:", newSpeed)
end)

ShakeChanged

Fired when the shake intensity changes

api.ShakeChanged:Connect(function(newIntensity)
print("Shake intensity changed to:", newIntensity)
end)

Client-only

Events

StartedWatching

Fired when the local player presses the Watch button

api.StartedWatching:Connect(function()
print("Player started watching")
end)

StoppedWatching

Fired when the local player unpresses the Watch button

api.StoppedWatching:Connect(function()
print("Player stopped watching")
end)