How to change player's Current Camera in a workspace script?

Hello,
Since today, I’ve been trying to change the player’s current camera type with a script. The script works with a local script, but not with a script.
I was unable to figure that out how to make it. The script does not work for some reason.

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
end)

Does anyone know how to make it? - Thanks :slight_smile:

2 Likes

LocalScripts only run in these places:

You will need to put your script in StarterPlayerScripts and change the variables.

If you’re doing this with a server script, use RemoteEvents to communicate to the client what to do.

1 Like

You should fire a remote , to that client and then change the camera on the client.

You should use FireClient

Server Script:

script.Parent.ClickDetector.MouseClick:Connect(function(plr)   
 game:GetService("ReplicatedStorage").Cam:FireClient(plr)
end)

Local Script:

local replicated = game:GetService("ReplicatedStorage")

replicated:WaitForChild("Cam").OnClientEvent:Connect(function()
    game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
end)
3 Likes