Hi, I'm making a 'To do list' system game. I have made the mechanic fine but when I list something in the text box, I go ahead and click my 'Add' button then it lists the task in all text columns. I wish I could explain better or give a picture but idk how. When I click the button the code runs on all 'if statements' doesn't wait till the next click.

The script is local located inside of StarterGui

local textBox = script.Parent.ScreenGui.Background.TextBox

local addButton = script.Parent.ScreenGui.Background.Add

local toDo1 = script.Parent.ScreenGui.Background.Frame.Todo1
local toDo2 = script.Parent.ScreenGui.Background.Frame.Todo2
local toDo3 = script.Parent.ScreenGui.Background.Frame.Todo3
local toDo4 = script.Parent.ScreenGui.Background.Frame.Todo4
local toDo5 = script.Parent.ScreenGui.Background.Frame.Todo5
local toDo6 = script.Parent.ScreenGui.Background.Frame.Todo6
local toDo7 = script.Parent.ScreenGui.Background.Frame.Todo7
local toDo8 = script.Parent.ScreenGui.Background.Frame.Todo8
local toDo9 = script.Parent.ScreenGui.Background.Frame.Todo9
local toDo10 = script.Parent.ScreenGui.Background.Frame.Todo10
local toDo11 = script.Parent.ScreenGui.Background.Frame.Todo11
local toDo12 = script.Parent.ScreenGui.Background.Frame.Todo12
local toDo13 = script.Parent.ScreenGui.Background.Frame.Todo13
local toDo14 = script.Parent.ScreenGui.Background.Frame.Todo14

local hasText = false
local taken = 1
	
textBox.Changed:Connect(function(newValue)
	
	addButton.MouseButton1Click:Connect(function()
		if taken == 1 then				
		toDo1.Text = textBox.Text
		print("Text Changed")
		taken = 2			
	end
		if taken == 2 then
		toDo2.Text = textBox.Text
		print("Text Changed")
		taken = 3
	end
		if taken == 3 then
		toDo3.Text = textBox.Text
		print("Text Changed")
		taken = 4
	end
		if taken == 4 then
		toDo4.Text = textBox.Text
		print("Text Changed")
		taken = 5
	end
		if taken == 5 then
		toDo5.Text = textBox.Text
		print("Text Changed")
		taken = 6
	end
		if taken == 6 then
		toDo6.Text = textBox.Text
		print("Text Changed")
		taken = 7
	end
		if taken == 7 then
		toDo7.Text = textBox.Text
		print("Text Changed")
		taken = 8
	end
		if taken == 8 then
		toDo8.Text = textBox.Text
		print("Text Changed")
		taken = 9
	end
		if taken == 9 then
		toDo9.Text = textBox.Text
		print("Text Changed")
		taken = 10
	end
		if taken == 10 then
		toDo10.Text = textBox.Text
		print("Text Changed")
		taken = 11
	end
		if taken == 11 then
		toDo11.Text = textBox.Text
		print("Text Changed")
		taken = 12
	end
		if taken == 12 then
		toDo12.Text = textBox.Text
		print("Text Changed")
		taken = 13
	end
		if taken == 13 then
		toDo13.Text = textBox.Text
		print("Text Changed")
		taken = 14
	end
		if taken == 14 then
		toDo14.Text = textBox.Text
		print("Text Changed")
		taken = 0
		end	
	end)
end)

Ik there's alot of copy pasting involved but that's what I did

Let me know if you can help me out thx.

2 comments

0

Because after each if statement you are setting [taken] to next number and then the other if statement will always pass it. You would need to turn all the if statements around from taken == 14 >>> to >>> taken == 1

0

I actually deleted the changed event and added another if statement that fixes it all but ty you helped as well.