I have no idea why this isn't working, the script below is supposed to trigger when a ScreenGui Button is clicked. It resets your camera and respawns your character, but it isn't working on a live server, whilst in studio, it works perfectly.
function onClicked() game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid game.Workspace.CurrentCamera.CameraType = "Custom" game.Players.LocalPlayer:LoadCharacter() script.Parent.MouseButton1Down:connect(onClicked)
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") -- added wait for child 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!