Hey folks, I’m trying to change the camera’s subject to a different part, but it doesn’t seem to be working. I read some other topics with the same issue as mine and changed up some things in my script, still no luck. Here is my script:
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local function resetCameraSubject()
if workspace.CurrentCamera and localPlayer then
local Katamari = localPlayer:FindFirstChildOfClass("Model")
if Katamari then
workspace.CurrentCamera.CameraSubject = Katamari:FindFirstChild("Katamari")
end
end
end
resetCameraSubject()
To me everything here seems like it should work, unless I got the type of script it should be or the service its in incorrect (normal script in serverscriptservice). Could anybody please point out what I’m doing wrong?
Why would you try to change the camera subject to something within the player, and not something within workspace? I believe to change the camerasubject, the new object has to be inside workspace. Also, LocalPlayer does not work in Server scripts, and works only inside of local scripts. Changing the CameraSubject will also only have an effect in local scripts as the player views the object Locally, not based on server.
LocalPlayer isn’t accessible from the server, and returns nil, so
will always fail and the code will never run. Even if it did run, there wouldn’t be any visible difference because you should use LocalScripts to change the CameraSubject.
Sorry to keep bothering you, but I made some changes to the script after putting it into startercharacterscripts, and it still doesn’t seem to be working.
local localPlayer = script.Parent
local function resetCameraSubject()
if workspace.CurrentCamera and localPlayer then
local Katamari = localPlayer.Katamari
if Katamari then
workspace.CurrentCamera.CameraSubject = Katamari:FindFirstChild("Katamari")
end
end
end
resetCameraSubject()
I remember an earlier reply mentioned that you could only change the camerasubject to something within the workspace and not within the player. I’m not sure if this is true, but could that be the problem?