Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this localscript not work?[PROBLEM SOLVED]

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

0

Are you sure this script is a LocalScript?

0

Lemme check it

0

Oh... You right :) it is a Script not a LocalScript, if i would accept this as an answer...

0

I'll make it an answer lol

1 answer

✓ Accepted answer

Are you sure this script is a LocalScript?

5 comments

1

lol

1

Now it says that "background2 is not a valid member of ScreenGui"

1

Oh never mind, i changed the background2 to "script.Parent.Parent.Background2" xD

0

gg

1

Taugh one.

This discussion is preserved as it was. New answers, comments, and votes are closed.