Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why my camera system only works in studio and not game?

Asked by 7 years ago
Edited 7 years ago

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)

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. RubenKan 3615 — 7y
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. charlesg9 5 — 7y
0
You don't need it in the title. We are able to tell if it isn't answered... Shawnyg 4330 — 7y
0
Is line 4 suppost to be if (w[i].className == "Camera") or (w[i].className == "Cam" .. shadownetwork 233 — 7y
View all comments (2 more)
0
Shouldn't it be: if w[i].className == "Camera" then shadownetwork 233 — 7y
0
Is this in a LocalScript or a Script? shadownetwork 233 — 7y

Answer this question