Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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")

1 comment

0

The Truss part is so Correct but the Camera going back to the Player is Broken.

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)

2 comments

0

No Difference.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.