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
9 years ago

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)

This Error kept popping up in the Output

Please Respect that I am a Beginner.

2 answers

Log in to vote
-1
Answered by 9 years ago

Make a LocalScript in the Backpack

local player = game.Players.LocalPlayer
cam = game.Workspace.CurrentCamera

player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextButton").MouseButton1Down:connect(function()
    cam.CameraSubject = player.Character.Humanoid

end)
cam.CameraSubject = game.Workspace:FindFirstChild("Truss")
0
The Truss part is so Correct but the Camera going back to the Player is Broken. woodengop 1134 — 9y
Ad
Log in to vote
-1
Answered by
wixoa 0
9 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:

button.TextButton.MouseButton1Down:connect(function(X, Y)
    cam.CameraSubject=game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
end)
0
No Difference. woodengop 1134 — 9y
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 — 9y

Answer this question