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)

6 comments

0

Why did you put (not solved) in the title. Pease edit and remove it as it sounds like you want us to hurry up. Be patient.

0

Ruben, i posted that because i need this fixed by next week. i have a roblox event im hosting which needs this type of camera.

0

You don't need it in the title. We are able to tell if it isn't answered...

0

Is line 4 suppost to be if (w[i].className == "Camera") or (w[i].className == "Cam" ..

0

Shouldn't it be: if w[i].className == "Camera" then

0

Is this in a LocalScript or a Script?