If your game has Filtering Enabled then that's a whole other answer. If you don't have it Enabled then this will work. As said above your not giving enough time for your script to load. In this case, we use WaitForChild on variables or straight to the function.
I will fix the script and tell you what I added
Fix;
function onClicked()
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
game.Workspace.CurrentCamera.CameraType = "Custom"
game.Players.LocalPlayer:LoadCharacter()
script.Parent.MouseButton1Down:connect(onClicked)
Here's a few stuff to look out!
If it still doesn't work try adding WaitForChild for the humanoid. if it still doesn't work after that then add WaitForChild on CurrentCamera as well. This is how you use wait for child functions
example;
game.Players.LocalPlayer.Character you add : then WaitForChild("Name")
there's also an example above in the fixed script.
Make sure you accept the answer and upvote if worked/helped
Any questions? Ask below! I will get back to you right away!
4 comments
Maybe you're not giving enough time for your script to load, try adding a wait() at the beginning.
Does your game implement Filtering Enabled?
Adding wait() at the top of your scripts is really ugly.
You're missing an end btw, and a connection to the function