I am making this Camera tool script for when the player switches to this tool, it hops straight to the camera to focus on the specific part.Unfortunately, this only works in studio due to a LocalPlayer problem. I cant understand how to fix it. any suggestions?
function onSelected(mouse) local w = game.Workspace:getChildren() for i = 1, #w do if (w[i].className == "Camera") or (w[i].className == "Cam" .. game.Players.LocalPlayer.Character.Name) then if w[i].CameraSubject == game.Players.LocalPlayer.Character.Humanoid then w[i].CameraSubject = game.Workspace:findFirstChild("CamCam1") end w[i].Name = "Cam" .. game.Players.LocalPlayer.Character.Name end end end function onDeselected(mouse) local w = game.Workspace:getChildren() for i = 1, #w do if (w[i].className == "Camera") then w[i].CameraSubject = game.Players.LocalPlayer.Character.Humanoid end end end script.Parent.Selected:connect(onSelected) script.Parent.Deselected:connect(onDeselected)