Variables into Text

local Number = game.workspace.Values.L1.Value

while true do wait()
    script.Parent.Text = Number
end
	
	 if workspace.Values.resettargets.Value == true then script.Parent.Text ="0"
					workspace.Values.L1.Value = 0
		end

I feel like this should be working but it is not, can anybody see an error?
image
image

The value does change so it’s not an issue with the value.

You are only checking if the value is true once. An if statement only runs once you have to put the if statement inside the while loop for it to keep checking the value of resettargets

Even with that line of code in the while true do the text does not change.

image

In case you were wondering resettargets is set to false to begin with so that cannot be affecting it.

local Number = game.workspace.Values.L1.Value

while true do wait()
script.Parent.Text = Number
end

workspace.Values.resettargets.Value.Changed:Connect(function()
if workspace.resettargets.Value == true then
script.Parent.Text = “0”
workspace.L1.Value = 0
end
end

try this ^^

I didn’t do that but um, I found something weird. It seems that if I use the direct path instead of local Number it works, odd.

while true do wait()
    script.Parent.Text = game.workspace.Values.L1.Value
	 if workspace.Values.resettargets.Value == true then script.Parent.Text ="0"
					workspace.Values.L1.Value = 0
		end
end
1 Like

The reason why it works like that is because Number is the value of L1 at the beginning and doesn’t change when L1’s value is changed.

3 Likes