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

Why is the Camera's Subject not a truss? [UNANSWERED]

Asked by
woodengop 1134 Moderation Voter
10 years ago

Why wouldn't the Camera's Subject be focused on the truss? Here is the Code:

01local cam=workspace.CurrentCamera
02local button=game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")
03-- In Line 2 SH cut off :WaitForChild("ScreenGui")
04game.Players.PlayerAdded:connect(function(plr)
05    cam.CameraSubject=workspace:FindFirstChild("Truss")
06end)
07 
08button.TextButton.MouseButton1Down:connect(function()
09    cam.CameraSubject=plr.Character:WaitForChild("Humanoid")
10end)

This Error kept popping up in the Output

Please Respect that I am a Beginner.

2 answers

Log in to vote
-1
Answered by 10 years ago

Make a LocalScript in the Backpack

1local player = game.Players.LocalPlayer
2cam = game.Workspace.CurrentCamera
3 
4player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextButton").MouseButton1Down:connect(function()
5    cam.CameraSubject = player.Character.Humanoid
6 
7end)
8cam.CameraSubject = game.Workspace:FindFirstChild("Truss")
0
The Truss part is so Correct but the Camera going back to the Player is Broken. woodengop 1134 — 10y
Ad
Log in to vote
-1
Answered by
wixoa 0
10 years ago

When you use the MouseButton1Down event on a TextButton, the 2 arguments in the function are where on the button it was clicked, not the player. Try doing this:

1button.TextButton.MouseButton1Down:connect(function(X, Y)
2    cam.CameraSubject=game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
3end)
0
No Difference. woodengop 1134 — 10y
0
Loos like you're trying to access the plr from the PlayerAdded event. You can't do that. Also, PlayerAdded doesn't seem to activate in LocalScripts. wixoa 0 — 10y

Answer this question