Problem:
So basically I want any input into the text field be converted into “●”, it does this kinda, but every 1 input the increases by a larger amount, for example:
What I’ve tried:
I have tried re writing it and adding delays as well as using Bings AI multiple times, but it only tells me to use a textchanged event that doesn’t exist and then links me “GetPropertyChangedSignal(“Text”)” which I am already using.
Correction:
It does only fire once but goes up in an inteval of:
1, 4, 13, 40, 121, 364…
So clearly it’s not firing multiple times, so something in the code is wrong, but I can’t figure out what.
Code:
------------------------------------------------------------------------------------------------------------
--// Locals
local LoginFrameScripts = script.Parent
local OceanOS = LoginFrameScripts.Parent
--
local LoginFrame = OceanOS.LoginFrame
local PINFrame = LoginFrame.PINFrame
local PINTextField = PINFrame.TextField
--
local Debounce = false
------------------------------------------------------------------------------------------------------------
--// TextField Animation and Management
PINTextField:GetPropertyChangedSignal("Text"):Connect(function()
if Debounce == false then
Debounce = true
local PIN = PINTextField.Text
local TextAmount = string.len(PIN)
PINTextField.Text = string.rep("●", TextAmount)
Debounce = false
end
end)
------------------------------------------------------------------------------------------------------------
Man It seems like you’re experiencing a problem where the number of bullet points (‘●’) increases exponentially with each input, which is likely due to the way you’re handling the Text property change in the Text field. I think The issue arises because each time you modify the Text property inside the TextChanged event handler, it triggers the event again, creating an infinite loop of updates. To solve this problem, you can create a debounce mechanism to control how the Text property is updated. Here’s a modified version of your code that should work as expected (btw I havent tested the script to know if its work im not really with my computer rn):
local LoginFrameScripts = script.Parent
local OceanOS = LoginFrameScripts.Parent
local LoginFrame = OceanOS.LoginFrame
local PINFrame = LoginFrame.PINFrame
local PINTextField = PINFrame.TextField
local Debounce = false
local function updateText()
if not Debounce then
Debounce = true
local PIN = PINTextField.Text
local TextAmount = string.len(PIN)
PINTextField.Text = string.rep("●", TextAmount)
Debounce = false
end
end
-- Create a variable to track the original text and update only when necessary
local originalText = ""
PINTextField.FocusLost:Connect(function(enterPressed)
if enterPressed then
-- Handle the Enter key press here
-- This is where you would process the PIN input
-- For now, we'll just reset the field
PINTextField.Text = string.rep("●", string.len(originalText))
end
end)
PINTextField:GetPropertyChangedSignal("Text"):Connect(function()
local currentText = PINTextField.Text
if currentText ~= originalText then
-- The Text property has changed, update the originalText and call the updateText function
originalText = currentText
updateText()
end
end)
dude In this modified code, we add a debounce mechanism to prevent the TextChanged event from being triggered multiple times in quick succession. We also use the FocusLost event to handle the Enter key press or any other action when the user has finished entering the PIN. The originalText variable is used to keep track of the original text in the field.
Yea that was my assumption, it does the same scaling increase with your code too, I really cant think of another way to do it, other than doing a hacky’ transparent text input then change a visible text label above it, but I would have liked to do it properly.
What I don’t get is that the debounce blocks if firing when it is converted to dots as it is turned off after the change is made, so how is it firing multiple times?
Even if I add a five second wait it does it, it wont set debounce to false until it runs and completes:
PINTextField.Text = string.rep(“●”, TextAmount)
edit: Also if this was the case it would act like it does without a debounce and run an infinite loop until it timed out, as it is it only fires 3 times.
This command is hard to work with. It’s not firing as perfectly as you would think.
This is like testing for when you’re not touching something. They just don’t fire like you think they are.