Best Way to Change Only One Person's Camera

local Camera = workspace.CurrentCamera
local CameraPlayer = game.ReplicatedStorage.CameraValues.Player
CameraPlayer.Changed:Connect(function(plr)
	if plr == game.Players.LocalPlayer.Name then
		Camera.CameraType = Enum.CameraType.Scriptable
		
		---Do whatever you want to type here.
	end
end)

Is this there a better way of changing only one player’s camera? I found this on the forum but I’m not 100% sure it’s efficient.

The method I’m using is changing a player’s camera when they step on a part (Last time I tried using remote events, it gave me some error saying I can’t use remote events in workspace).

Any help is appreciated, thanks.

On the server, fire a remote event in replicated storage.

remoteEvent:FireClient()

Your method will not work very well. You should read up on remote events as it is the only safe and reliable way to do this.

I’m not too sure what you mean by “change one persons camera.”
if you want it to switch when you touch a part, just use .Touched and change the camera on the client using a LocalScript. I don’t believe events are nessessary.

I’m pretty sure Local Scripts don’t run in Workspace though.

1 Like

They do not work inside of workspace.

You don’t need to have the LocalScript in the workspace?
Put it in StarterCharacter / StarterPlayer and use a variable to reference the part you want to use .Touched on.

2 Likes

This is unrelated, but how would I run a .Touched event for multiple parts using an i,v loop?

I might be wrong here, but this should work (someone correct me if I’m wrong). You can throw them all in a folder and if any of them are touched they will do the same thing.

for i, v in ipairs(workspace.Folder:GetChildren()) do
	if v:IsA("Part") then
		v.Touched:Connect(function()
			--Code
		end)
	end
end
1 Like