TextBox Text not changing when running this function

Trying to make Text turn into Tables String when you click a SurfaceGUI Button and when you click it runs a function

I’m not entirely sure why, but It’s not working, no errors at all

I’ve tried looking for solutions but none of them worked at all and couldn’t find many

QuestionTable = {
	"Do you have a son?", --1
	"Are you POSITIVE that you are alone in the building?", --2
	"Ok, well let the torture continue.", --3
	"Are you tired?", --4
	"Wait, you're back? You already beat this game.", --5
	"Is your favorite color "..colorpicked.."?", --6
	"Have you ever cried yourself to sleep?", --7
	"This is just a game, you know that right?", --8
	
	
}


--[{End Of Customization, Don't Touch Below}]


--[{NextQuestion(QuestionTable[1], 1, AnswerTable[1])}]

function NextQuestion(Question,SecondsAfter,Reply)
	Debounce = false
	NoButton.Visible = false
	YesButton.Visible = false
	NumberVal.Value = NumberVal.Value + 1
	if (Reply == "NoReply") then 	--[{NextQuestion(QuestionTable[1], 1, NoReply)}]
		QuestionBox.Text = QuestionTable[Question].Text
		wait(SecondsAfter)
		NoButton.Visible = true
		YesButton.Visible = true
	else
		QuestionBox.Text = AnswerTable[Reply].Text
		wait(SecondsAfter)
		QuestionBox.Text = QuestionTable[Question].Text
		wait(SecondsAfter)
		NoButton.Visible = true
		YesButton.Visible = true
	end
	wait(1)
	Debounce = true
end

script.Parent.yes.MouseButton1Down:Connect(function()
	PlayerPressedYes = true
end)

function YesPressed()
	if Debounce == true then
		if NumberVal == 0 then
			if BadgeService:UserHasBadgeAsync(LocalPlayerUser, 2124592064) then
				NextQuestion(5, 1, "NoReply")
			else
				NextQuestion(5, 1, "NoReply")
			end
		end		
	end
end

script.Parent.yes.MouseButton1Down:Connect(function()
	YesPressed()
end)

Have you defined debounce as a variable before the functions?

Yes, I have defined debounce before the function

In which case it would be helpful if we had all the code, not just some of it.

Gotcha,

--[{Vars}]
LocalPlayerUser = game.ReplicatedStorage.Values:WaitForChild("LocalPlayerUser")
PlayerUserId = game.ReplicatedStorage.Values:WaitForChild("LocalPlayersID")
PlayerService = game:GetService("Players")
ServerStorage = game:GetService("ServerStorage")
BadgeService = game:GetService("BadgeService")
QuestionBox = script.Parent:WaitForChild("question")
YesButton = script.Parent:WaitForChild("yes")
NoButton = script.Parent:WaitForChild("no")
NumberVal = script.Parent:WaitForChild("number")
PlayerPressedYes = false
PlayesPressedNo = false
Debounce = true

--[{Start of Customization}]

Colorlist = {
	"red",
	"blue",
	"green",
	"yellow",
	"purple",
	"pink",
	"black"
}

--[{Picks Random Color From Table}]
randomizedcolor = math.random(1,#Colorlist)
colorpicked = Colorlist[randomizedcolor]


AnswerTable = {
	"Ok.",
	"By your hand, that answer is no longer correct.",
}

QuestionTable = {
	"Do you have a son?", --1
	"Are you POSITIVE that you are alone in the building?", --2
	"Ok, well let the torture continue.", --3
	"Are you tired?", --4
	"Wait, you're back? You already beat this game.", --5
	"Is your favorite color "..colorpicked.."?", --6
	"Have you ever cried yourself to sleep?", --7
	"This is just a game, you know that right?", --8
	
	
}


--[{End Of Customization, Don't Touch Below}]


--[{NextQuestion(QuestionTable[1], 1, AnswerTable[1])}]

function NextQuestion(Question,SecondsAfter,Reply)
	Debounce = false
	NoButton.Visible = false
	YesButton.Visible = false
	NumberVal.Value = NumberVal.Value + 1
	if (Reply == "NoReply") then 	--[{NextQuestion(QuestionTable[1], 1, NoReply)}]
		QuestionBox.Text = Question
		wait(SecondsAfter)
		NoButton.Visible = true
		YesButton.Visible = true
	else
		QuestionBox.Text = AnswerTable
		wait(SecondsAfter)
		QuestionBox.Text = Question
		wait(SecondsAfter)
		NoButton.Visible = true
		YesButton.Visible = true
	end
	wait(1)
	Debounce = true
end

function YesPressed()
	if Debounce == true then
		if NumberVal == 0 then
			if BadgeService:UserHasBadgeAsync(LocalPlayerUser, 2124592064) then
				NextQuestion(QuestionTable[5], 1, "NoReply")
			else
				NextQuestion(QuestionTable[5], 1, "NoReply")
			end
		end		
	end
end

script.Parent.yes.MouseButton1Down:Connect(function()
	YesPressed()
end)

Within your first variables put local before them all as I’ll show below, if there are no errors then it’s most likely just the logic behind it.

local LocalPlayerUser = game.ReplicatedStorage.Values:WaitForChild("LocalPlayerUser")
local PlayerUserId = game.ReplicatedStorage.Values:WaitForChild("LocalPlayersID")
local PlayerService = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local BadgeService = game:GetService("BadgeService")
local QuestionBox = script.Parent:WaitForChild("question")
local YesButton = script.Parent:WaitForChild("yes")
local NoButton = script.Parent:WaitForChild("no")
local NumberVal = script.Parent:WaitForChild("number")
local PlayerPressedYes = false
local PlayesPressedNo = false
local Debounce = true

I’d go through thoroughly and ensure that all of the logic behind it is correct, should something be visible where it isn’t. I don’t see anything in terms of the scripting.

I’ve went through it a few times but I don’t know what exactly is wrong that’s the problem, I have no clue what to change

Try putting a print("hello") at the start of the script, if it doesn’t print, your script isn’t running. What type of script is this? If it is a server (“normal”) script, change it to a localscript and make sure the localscript is parented under startergui; replicatedfirst; or a starterPlayer container. Also, more info might be helpful. If it just isn’t doing anything, I assume it’s this, but if it does something but not what you want it to do, then this won’t be your issue.

It’s printing correctly but nothing is working and nothing happening I added a print to the function