Team Create Camera Restore Plugin


Team Create Camera Restore saves your camera position in Team Create and reloads it when you rejoin a Team Create session with the same PlaceId.

Camera position is saved…

  • Every 10 seconds
  • When the game closes, if possible.
  • Only if the current CFrame is different from the last CFrame.

It’s automatic. Simple and easy to use!


Source
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local NetworkClient = game:FindService("NetworkClient")
--              is running | has localplayer | has network client
-- normal:        no           no                no
-- play solo:     no           yes               no
-- server:        yes          no                no
-- client:        yes          yes               yes
-- team create:   no           yes               yes

local prefix = "TCCameraRestore_"
local prefixFocus = prefix.."focus_"

if not RunService:IsRunning() and Players.LocalPlayer and NetworkClient then
	local settingsId = prefix..game.PlaceId
	local settingsIdFocus = prefixFocus..game.PlaceId
	local lastCFrame, lastFocus
	local function save()
		local camera = workspace.CurrentCamera
		if camera.CFrame ~= lastCFrame then
			plugin:SetSetting(settingsId, {camera.CFrame:components()})
			lastCFrame = camera.CFrame
		end
		if camera.Focus ~= lastFocus then
			plugin:SetSetting(settingsIdFocus, {camera.Focus:components()})
			lastFocus = camera.Focus
		end
	end
	local function load()
		lastCFrame = plugin:GetSetting(settingsId)
		lastFocus = plugin:GetSetting(settingsIdFocus)
		if lastCFrame then
			workspace.CurrentCamera.CFrame = CFrame.new(unpack(lastCFrame))
		end
		if lastFocus then
			workspace.CurrentCamera.Focus = CFrame.new(unpack(lastFocus))
		end
	end
	
	load()
	
	-- BindToClose doesn't work because it's the "client" >:(
	pcall(function()  -- OnClose will fail to set if it's already set by something else.
		game.OnClose = function()
			save()
		end
	end)
	while true do
		wait(10)
		save()
	end
end

Public post

6 Likes