Why doesn't this script work?

Both versions are acceptable (30c)

1 Like

Yes, workspace acts the same as game.Workspace.

1 Like

Just a question, what value has the variable enabled at the beggining?

The
local Enabled = false
Was part of the tutorial I watched.

Maybe u should replace it with true

in the tutorial, The person wrote “local Enabled = false”
I tried switching it to local Enabled = true and it still did not do anything.

1 Like

Like its just logical to me

if not Enabled then -- if Enabled == true then
		Enabled = true -- why would u do that?

Well, I followed the tutorial and the person said to write that, If you want to watch the tutorial for yourself, Its here: https://www.youtube.com/watch?v=LyXgJNuQriw

Oh wait, Hold on, I think I did something wrong. Let me try this…
I didn’t add the script that the person put in starterpack.

U know the thing is u are disableing and enabling cameras but u never mess withe the camera properties

You know what, I tried all the possible ways, I will just add an image like this:


and pretend they are seeing the game from a different view.

1 Like

Hey there! After reviewing your script for a couple of minutes, I think I found out the issue.
You had a couple ends that were not in the right place, which were breaking the code.

also indented the code a little

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()
		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.Name, "has regular NPC Dialogue Settings...")
		ContinueBtn.Visible = true
		CloseBtn.Visible = true
		CloseBtn.MouseButton1Click:Connect(function()
			--script.Parent.Frame.Visible = false
		end)
	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
	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
		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)


Let me know if it works, if you have any questions or if the script is not working, you can reply below.

Quick Edit: had a typo

This is totally unnecessary and just makes a big mess in your script. If you are going to change the text like that I recommend using a for loop and string.sub(): string | Documentation - Roblox Creator Hub

Another thing with scripting is to make sure you indent your code as it seems ends breaking your code could have been your problem as @EndurableRayy said up top.

1 Like

I am sure there is a much easier way rather than repeating textLabel.Value again and again.

This is unnecessary, try this:

 local text = "Hey There! You Might not know me, But I found you in this cave lying down!"

 for i = 1,#text do

 script.Parent.Text = string.sub(text, 1, i)

 wait(0.01)

 end
2 Likes

Yes, I know my bad was just trying to fix his code that he provided

Did you check the console? (30 characters)

local camera = game.Workspace.CurrentCamera
YourGui.MouseButton1Click:Connect(function()
 if enabled == false then
     enabled = true   
 camera.CameraType = "Scriptable" 
    camera.CFrame = game.Workspace.CamPart.CFrame
else
    camera.CameraType = "Custom"
 enabled = false
end
end)

Sth like this, also I am sorry for weird structure (I am on phone) also probably I missed sth but do sth into this direction. Also make a part named CamPart and put it into workspace

Yep, 2 errors in the console…

1 Like

I think you meant
local camera = workspace.CameraPart1

No I didnt that camera variable is getting ur camera so u can mess with it