Hi. I’m creating a visual novel from scratch and I have one problem…
I have a function that outputs text, and then the function is only ended when the player clicks a button. I’ve noticed that when a new function is called, the function that is called when the button is pressed is called more and more often.
An example of what I’m talking about:
module.text(RandomDude, "Text")
Pressed
module.text(RandomDude, "Text")
Pressed (x2)
module.text(RandomDude, "Text")
Pressed (x3)
The function is called more each time.
Devices start to lag when pressed
Code (Only the important lines):
function module.text(char, text)
if Settings.EventSettings.Launched == false then return false end
local val = false
local function Pressed() print("Pressed") val = true return true end
local function AutoPressed() print("Fire Auto!") task.wait(Settings.MainSettings.AutoDelay) Pressed() return end
local Gui = Settings.MainSettings.Gui
local Button = Gui.VisualNovel.Button
------------------------------------------------------
--The function of the Gui module is called here
------------------------------------------------------
Button.MouseButton1Click:Connect(Pressed)
AutoEvent.Event:Connect(AutoPressed)
if Settings.EventSettings.Auto == true then AutoEvent:Fire() end
repeat wait() until val == true
return true
end
I couldn’t find anything similar on DevForum and Assistant is also powerless.