I made a localscript what i used to manipulate the camera of a Player, it worked well but when i press a button what needs to make it go back to the player does not work well.
In studio it worked good without any errors in Output, but when i tested it in Roblox Player it didn't do the same, it didn't remove the Frame what has the code after the line what changes the CameraSubject to the Players Humanoid.
Here is the code i used, i'm going to put some Comments where the code has the problem.
local Button = script.Parent
local background = script.Parent.Parent.Background
local background2 = script.Parent.Parent.Background2
function close()
if script.Parent.Value.Value == false then
script.Parent.Value.Value = true
script.Parent.AutoButtonColor = false
wait(0.001)
for i=1,100 do
Button.BackgroundTransparency = Button.BackgroundTransparency + 0.01
Button.TextTransparency = Button.TextTransparency + 0.01
wait(0.005)
end
Button.Visible = false
wait(0.001)
for i=1,100 do
background.BackgroundTransparency = background.BackgroundTransparency + 0.01
background.ImageTransparency = background.ImageTransparency + 0.01
background2.BackgroundTransparency = background2.BackgroundTransparency - 0.01
wait(0.01)
end
background.Visible = false
wait(0.001)
script.Parent.Parent.Parent.LocalScript.Value.Value = false
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid --The console says here is the problem
wait(0.001)
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
wait(1)
for i=1,100 do
background2.BackgroundTransparency = background2.BackgroundTransparency + 0.01
script.Parent.Parent.Seoul.ImageTransparency = script.Parent.Parent.Seoul.ImageTransparency + 0.01
wait(0.01)
end
background2.Visible = false
script.Parent.Parent.Seoul.Visible = false
end
end
Button.MouseButton1Click:connect(close)
Here is the error in the Developers Console:
Players.lehel55.PlayerGui.ScreenGui.Play.Script:26: attempt to index field 'LocalPlayer' (a nil value) Stack Begin Script 'Players.lehel55.PlayersGui.ScreenGui.Play.Script', Line 26 Stack End

4 comments
Are you sure this script is a LocalScript?
Lemme check it
Oh... You right :) it is a Script not a LocalScript, if i would accept this as an answer...
I'll make it an answer lol