When a player clicks a button on a GUI, he is supposed to be respawned and his camera is meant to go back to his character (I have an intro where it manipulates the camera).
The player being "respawned" (LoadCharacter()) works, however, the camera does not go back to the player's character?
script.Parent.MouseButton1Click:connect(function() local plr = game.Players.LocalPlayer plr:LoadCharacter() plr.CharacterAdded:connect(function() game.Workspace.CurrentCamera.CameraSubject = plr.Character.Humanoid game.Workspace.CurrentCamera.CameraType = "Custom" end) end)
Take the second function out of the first.
Your code isn't working because you have an unnecessary embedded function. Your code should look like this,
local plr = game.Players.LocalPlayer--Moving variables to the top causes less micro lag. script.Parent.MouseButton1Down:connect(function()--Using MouseButtonOneDown is better in my opinion. plr:LoadCharacter() end) plr.CharacterAdded:connect(function() game.Workspace.CurrentCamera.CameraSubject = plr.Character.Humanoid game.Workspace.CurrentCamera.CameraType = "Custom" end)
That's all. Good Luck!