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

Why can't I reset the players camera?

Asked by
Azmidium 388 Moderation Voter
8 years ago

I was reading through the wiki, and I was learning about camera manipulation. I finally figured out how to get the camera to move to where I want... How do I get it back?

I tried doing this..

-- Localscript
wait()
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Custom"

I undisabled the script when I need it, but then I get this error..

20:22:28.729 - Humanoid is not a valid member of Model 20:22:28.729 - Script 'Players.Player.Backpack.WalkAround', Line 2

1 answer

Log in to vote
0
Answered by
DevArk 50
8 years ago

When working with a localscript for a player you always want to make a for loop to wait for the player's character because it is the last of the player's data to load so once it loads the character is ready to be modified.

Also while looking for something's child you want to use the :FindFirstChild() just so that you avoid errors.

local player = game.Players.LocalPlayer
repeat wait() until player.Character
game.Workspace.CurrentCamera.CameraSubject = player.Character:FindFirstChild('Humanoid')
game.Workspace.CurrentCamera.CameraType = "Custom"
Ad

Answer this question