Why wouldn't the Camera's Subject be focused on the truss? Here is the Code:
local cam=workspace.CurrentCamera local button=game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui") -- In Line 2 SH cut off :WaitForChild("ScreenGui") game.Players.PlayerAdded:connect(function(plr) cam.CameraSubject=workspace:FindFirstChild("Truss") end) button.TextButton.MouseButton1Down:connect(function() cam.CameraSubject=plr.Character:WaitForChild("Humanoid") end)
I want the Camera's Subject to go back to the Humanoid when the Gui is clicked.
This Error kept popping up in the Output
Please Respect that I am a Beginner.
The variable "plr" is specific to the PlayerAdded function. By that, I mean "plr" can only be used inbetween game.Players.PlayerAdded:connect(function(plr)
and end)
. I'll just rewrite your script for you and explain it, since it would be more work just to explain the errors and have you rewrite it. I don't mean to be rude in any way in this answer.
--let's try this script, eh? local player = game.Players.LocalPlayer --defines player local camera = workspace.CurrentCamera --defines camera local button = player:FindFirstChild("PlayerGui"):FindFirstChild("ScreenGui"):FindFirstChild("TextButton") --defines button camera.CameraSubject = workspace:FindFirstChild("Truss") --makes CameraSubject "Truss" button.MouseButton1Click:connect(function() --button click event camera.CameraSubject = player.Character:FindFirstChild("Humanoid") --makes CameraSubject "Humanoid" end) --end, obviously
Notice how I removed the PlayerAdded event. I did that because it's not necessary. Keep in mind that this LocalScript has to be either directly or indirectly in StarterGui or StarterPack.