How Would I Manipulate Everyone's Camera At Once? (Server Side)

I want to make it so that if a Player in the Server clicks on a block, everyone’s camera in the server gets moved (manipulated) to view a certain position.

The thing is, I’m new to camera scripting and just scripting in general as well, so I watched some tutorials but well, they all used LocalScripts so only that player’s Camera was manipulated.

Now, how would I do this? I know I’d use a clickdetector.

This is the script that makes things move when one person in the server clicks a certain block. I want to add some lines so it moves EVERYONE’s camera to the moving parts when I click it. SERVERSCRIPT.

local clickdetector = game.Workspace.Ilum.Walls.DontTouchThis.ClickThis.ClickDetector
local GroupID = 8551076
local minimumRank = 60
local IlumOpen = false

local TweenService = game:GetService("TweenService")
local movingPart1 = game.Workspace.Ilum.Walls.SpecialWalls.Swall1:WaitForChild("CoreMovingPart") -- WaitForChild
local tweeningInformation = TweenInfo.new(
	3,    
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)
local Open = {CFrame = CFrame.new(-39.27, 162.996, -1125.513)}
local Close = {CFrame = CFrame.new(-29.27, 162.996, -1125.513)}
local tween1open = TweenService:Create(movingPart1,tweeningInformation,Open)
local tween1close = TweenService:Create(movingPart1,tweeningInformation,Close)


clickdetector.MouseClick:Connect(function(Player)
	if Player:GetRankInGroup(GroupID) >= minimumRank then
		if IlumOpen == false then
			tween1open:Play()
			IlumOpen = true
		elseif IlumOpen == true then
			tween1close:Play()
			IlumOpen = false
		end
	end
end)
1 Like

It isn’t possible to directly manipulate cameras from the server (it isn’t replicated across the client/server boundary).

You could, however, use RemoteEvents to fire all of the clients and then handle the camera movement on the client.

1 Like

So I ran this script:

(LocalScript)

local TweenService = game:GetService("TweenService")

local camera = game.Workspace.Camera

local cutsceneTime = 5

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("IlumOpenEvent")


local TweenInfo = TweenInfo.new(
	cutsceneTime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	false,
	0

)

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(cutsceneTime)

	camera.CameraType = Enum.CameraType.Custom

end


remoteEvent.OnClientEvent:Connect(tween(game.Workspace.Ilum.Camera1 , game.Workspace.Ilum.Camera2))

but it doesn’t work, it says

- attempt to call a nill value

How would I fix this?

1 Like

Does it say which line it’s on?

1 Like

I’m not sure, this is all it says.
image

1 Like

Oh wait I think I see.

You’re calling it, just :Connect(tween) should suffice.

1 Like

Never mind, I think it’s on line 36.


https://gyazo.com/6121db11bc61281b4e195ff9179e570d

1 Like

Oh, alright. Thanks, I’ll try.

1 Like

You can just get everyone’s camera by using “for i, v in pairs(game.Players:GetChildren()) do” and then you can manipulate everyone’s camera at the same time.

2 Likes

Well it doesn’t work, maybe because it’s a function and it has arguments?

1 Like

You can’t do that from the server as CurrentCamera isn’t replicated from client to server or vice versa.

The arguments should be passed without having to put them in the connect.

Instead of function tween(part1, part2), do

remoteEvent.OnClientEvent:Connect(function(part1, part2)

If it doesn’t work, could you post your server script?

1 Like

Uhh, so you want me to run

local TweenService = game:GetService("TweenService")

local camera = game.Workspace.Camera

local cutsceneTime = 5

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("IlumOpenEvent")


local TweenInfo = TweenInfo.new(
	cutsceneTime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	false,
	0

)

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(cutsceneTime)

	camera.CameraType = Enum.CameraType.Custom

end


remoteEvent.OnClientEvent:Connect(function(game.Workspace.Ilum.Camera1,game.Workspace.Ilum.Camera2))

?

1 Like

Ohhh wait, never mind. Let me fix that real quickly.

1 Like
local TweenService = game:GetService("TweenService")

local camera = game.Workspace.Camera

local cutsceneTime = 5

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("IlumOpenEvent")


local TweenInfo = TweenInfo.new(
	cutsceneTime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	false,
	0

)

removeEvent.OnClientEvent:Connect(function(part1, part2)
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = part1.CFrame

	local tween = TweenService:Create(camera, TweenInfo ,{CFrame  =  part2.CFrame})
	tween:Play()

	wait(cutsceneTime)

	camera.CameraType = Enum.CameraType.Custom

end
1 Like

Wouldn’t I have to define part1 and part2?

1 Like

Nope, they’re passed from the server.

1 Like

It still doesn’t work, so here’s the ServerScript.

local clickdetector = game.Workspace.Ilum.Walls.DontTouchThis.ClickThis.ClickDetector
local GroupID = 8551076
local minimumRank = 60
local IlumOpen = false

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("IlumOpenEvent")


local TweenService = game:GetService("TweenService")
local movingPart1 = game.Workspace.Ilum.Walls.SpecialWalls.Swall1:WaitForChild("CoreMovingPart") -- WaitForChild
local tweeningInformation = TweenInfo.new(
	3,    
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)
local Open = {CFrame = CFrame.new(-39.27, 162.996, -1125.513)}
local Close = {CFrame = CFrame.new(-29.27, 162.996, -1125.513)}
local tween1open = TweenService:Create(movingPart1,tweeningInformation,Open)
local tween1close = TweenService:Create(movingPart1,tweeningInformation,Close)


clickdetector.MouseClick:Connect(function(Player)
	if Player:GetRankInGroup(GroupID) >= minimumRank then
		if IlumOpen == false then
			tween1open:Play()
			IlumOpen = true
			remoteEvent:FireAllClients()
		elseif IlumOpen == true then
			tween1close:Play()
			IlumOpen = false
		end
	end
end)
1 Like

Oh, should I do tween1close:Play(game.Workspace.Ilum.Camera1,game.Workspace.Ilum.Camera2)?

oh frick, I meant remoteEvent:FireAllClients(game.Workspace.Ilum.Camera1,game.Workspace.Ilum.Camera2)

NOW IT WORKS! THANK YOU SO MUCH! :smile:

2 Likes