I made a local function that contains a loop that is always set to true, and inside that loop there is a check if “textboolvalue” is true or false. Inside the check if the value is false, there is a function for a textbutton and when clicking on this button, the “textboolvalue” will be true and will print “done” ending up infinitely printing “now is true”. But there is a problem, when the “done” is printed, instead of being once, it will print hundreds of times and only then will it go to “now is true”, what I want is for the “done” be printed only once, what do I do?
Code:
local textboolvalue = false
local function test()
while true do
wait()
if textboolvalue == false then
script.Parent.TextButton.MouseButton1Click:Connect(function()
textboolvalue = true
print(“done”)
end)
elseif textboolvalue == true then
print(“now is true”)
end
end
end
spawn(test)
Output: