Why doesn't this script work?

Hello Developers!
I was scripting my NPC while I stumbled apon a YouTube video about how to make “Camera Manipulation” I tried it and it doesn’t work. It started to not work when I wrote

ChangeCameraBtn.MouseButton1Click:Connect(function()
if not Enabled then
Enabled = true
game.Players.LocalPlayer.Backpack.Cameras.Disabled = false
else
Enabled = false
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
game.Players.LocalPlayer.Backpack.Cameras.Disabled = true
end

So I went down to the video’s comments and everyone said it worked. It did not work for me. Here is my full script:

local part = workspace.TalkPart1
local textlabel = script.Parent.Frame.TextLabel
local CloseBtn = script.Parent.Frame.CloseBtn
local ContinueBtn = script.Parent.Frame.ContinueBtn
local ChangeCameraBtn = script.Parent.Frame.ChangeCameraBtn
local player = game.Players.LocalPlayer
local PlayerCancelledDialogue = print("A Player has Cancelled their NPC Conversation.")
local PlayerContinuedDialogue = print("A Player has Continued their NPC Conversation.") 
local Enabled = false
local CameraPart1 = workspace.ca

part.ClickDetector.MouseClick:Connect(function()
script.Parent.Frame.Visible = true

wait(0.2)
textlabel.TextScaled = true
textlabel.Text = "H"
wait(0.1)
textlabel.Text = "He"
wait(0.1)
textlabel.Text = "Hey"
wait(0.1)
textlabel.Text = "Hey "
wait(0.1)
textlabel.Text = "Hey T"
wait(0.1)
textlabel.Text = "Hey Th"
wait(0.1)
textlabel.Text = "Hey The"
wait(0.1)
textlabel.Text = "Hey Ther"
wait(0.1)
textlabel.Text = "Hey There"
wait(0.1)
textlabel.Text = "Hey There!"
wait(0.1)
textlabel.Text = "Hey There! "
wait(0.1)
textlabel.Text = "Hey There! Y"
wait(0.1)
textlabel.Text = "Hey There! Yo"
wait(0.1)
textlabel.Text = "Hey There! You"
wait(0.1)
textlabel.Text = "Hey There! You M"
wait(0.1)
textlabel.Text = "Hey There! You Mi"
wait(0.1)
textlabel.Text = "Hey There! You Mig"
wait(0.1)
textlabel.Text = "Hey There! You Migh"
wait(0.1)
textlabel.Text = "Hey There! You Might"
wait(0.1)
textlabel.Text = "Hey There! You Might"
wait(0.1)
textlabel.Text = "Hey There! You Might n"
wait(0.1)
textlabel.Text = "Hey There! You Might no"
wait(0.1)
textlabel.Text = "Hey There! You Might not"
wait(0.1)
textlabel.Text = "Hey There! You Might not "
wait(0.1)
textlabel.Text = "Hey There! You Might not k"
wait(0.1)
textlabel.Text = "Hey There! You Might not kn"
wait(0.1)
textlabel.Text = "Hey There! You Might not kno"
wait(0.1)
textlabel.Text = "Hey There! You Might not know"
wait(0.1)
textlabel.Text = "Hey There! You Might not know "
wait(0.1)
textlabel.Text = "Hey There! You Might not know m"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me,"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, "
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, B"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, Bu"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But "
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I f"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I fo"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I fou"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I foun"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found "
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found y"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found yo"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you i"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in "
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in t"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in th"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in thi"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this "
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this c"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this ca"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cav"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave "
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave l"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave ly"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave lyi"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave lyin"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave lying"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave lying "
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave lying d"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave lying do"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave lying dow"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave lying down"
wait(0.1)
textlabel.Text = "Hey There! You Might not know me, But I found you in this cave lying down!"
wait(0.1)

wait(3)
print("Checking if", player, "has regular NPC Dialogue Settings...")
ContinueBtn.Visible = true
CloseBtn.Visible = true
CloseBtn.MouseButton1Click:Connect(function()
script.Parent.Frame.Visible = false
end)
ContinueBtn.MouseButton1Click:Connect(function()
if textlabel.TextScaled == false then
	textlabel.TextScaled = true
	print("Error; A Player had their NPC TextLabel settings change from regular.")
end
ChangeCameraBtn.MouseButton1Click:Connect(function()
	if not Enabled then
		Enabled = true
		game.Players.LocalPlayer.Backpack.Cameras.Disabled = false
	else
		Enabled = false
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		game.Players.LocalPlayer.Backpack.Cameras.Disabled = true
	end
end
print("The Player", player,"Has been checked successfully.")

textlabel.Text = "I"
wait(0.1)
textlabel.Text = "I'"
wait(0.1)
textlabel.Text = "I'm"
wait(0.1)
textlabel.Text = "I'm "
wait(0.1)
textlabel.Text = "I'm M"
wait(0.1)
textlabel.Text = "I'm Mo"
wait(0.1)
textlabel.Text = "I'm Mor"
wait(0.1)
textlabel.Text = "I'm Morg"
wait(0.1)
textlabel.Text = "I'm Morga"
wait(0.1)
textlabel.Text = "I'm Morgan"
wait(0.1)
textlabel.Text = "I'm Morgan!"
wait(2)
textlabel.Text = "L"
wait(0.1)
textlabel.Text = "Li"
wait(0.1)
textlabel.Text = "Lis"
wait(0.1)
textlabel.Text = "List"
wait(0.1)
textlabel.Text = "Liste"
wait(0.1)
textlabel.Text = "Liste"
wait(0.1)
textlabel.Text = "Listen,"
wait(0.1)
textlabel.Text = "Listen, W"
wait(0.1)
textlabel.Text = "Listen, We"
wait(0.1)
textlabel.Text = "Listen, We "
wait(0.1)
textlabel.Text = "Listen, We d"
wait(0.1)
textlabel.Text = "Listen, We do"
wait(0.1)
textlabel.Text = "Listen, We don"
wait(0.1)
textlabel.Text = "Listen, We don'"
wait(0.1)
textlabel.Text = "Listen, We don't"
wait(0.1)
textlabel.Text = "Listen, We don't"
wait(0.1)
textlabel.Text = "Listen, We don't "
wait(0.1)
textlabel.Text = "Listen, We don't h"
wait(0.1)
textlabel.Text = "Listen, We don't ha"
wait(0.1)
textlabel.Text = "Listen, We don't hav"
wait(0.1)
textlabel.Text = "Listen, We don't have"
wait(0.1)
textlabel.Text = "Listen, We don't have "
wait(0.1)
textlabel.Text = "Listen, We don't have t"
wait(0.1)
textlabel.Text = "Listen, We don't have th"
wait(0.1)
textlabel.Text = "Listen, We don't have tha"
wait(0.1)
textlabel.Text = "Listen, We don't have that"
wait(0.1)
textlabel.Text = "Listen, We don't have that "
wait(0.1)
textlabel.Text = "Listen, We don't have that m"
wait(0.1)
textlabel.Text = "Listen, We don't have that mu"
wait(0.1)
textlabel.Text = "Listen, We don't have that muc"
wait(0.1)
textlabel.Text = "Listen, We don't have that much"
wait(0.1)
textlabel.Text = "Listen, We don't have that much t"
wait(0.1)
print("script will be finished after fixing it...")
end)
end)
3 Likes

If you are wondering what video I watched, It was this one: https://www.youtube.com/watch?v=LyXgJNuQriw

1 Like

Do you have any errors in Dev Console?

2 Likes

Could you tell us what exactly doesn’t work?

Also, please put the code in a code block to make it easier to read…

2 Likes

Is this the code block’s icon?Screenshot_58

No error popped up in the console, But the script does not work anymore.

1 Like

To use the code block feature, simply type ```lua and then anything you type after will be in the code block.

local x = "Something"

print(x)
1 Like

local test = print("this is a test")

```lua

local test = print(“this is a test”)


local test = print(“this is a test”)
2 Likes

The codeblock works but why doesn’t my script work?

1 Like

It would be easier to understand if you used a code block. You can edit the OP to have the code block. Is there any errors in output or dev console?

No, No error popped up in the dev console, The script just doesn’t work anymore.

Not sure why your script doesn’t work. Check the developer console, make sure there are no typos and test the game again. Note that the creator of the video pinned a comment saying:

I would just like to point out that this video was meant to demonstrate the usage of camera manipulation, and not something you should directly copy.

Did it use to work? You could have changed the chain, to mak the locals invalid. Is this a server script, or a local script? And is it in server script service?

1 Like

It used to work before I added:

ChangeCameraBtn.MouseButton1Click:Connect(function()
	if not Enabled then
		Enabled = true
		game.Players.LocalPlayer.Backpack.Cameras.Disabled = false
	else
		Enabled = false
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		game.Players.LocalPlayer.Backpack.Cameras.Disabled = true
	end
end

Why don’t you just switch it back then?

If I switch it back then the Player’s camera view will not change to this view:

game.workspace acts the same as workspace

I will try it, But it will probably be the same but I will still try.

But it used to work even if it’s workspace, The thing that made the script stop working is

ChangeCameraBtn.MouseButton1Click:Connect(function()
	if not Enabled then
		Enabled = true
		game.Players.LocalPlayer.Backpack.Cameras.Disabled = false
	else
		Enabled = false
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		game.Players.LocalPlayer.Backpack.Cameras.Disabled = true
	end
end```

Also I just tried switching it to game.Workspace, And it still does the same exact thing(Nothing).