#Script running a function multiple times
22 messages · Page 1 of 1 (latest)
because each spin it duplicates the function that the user didnt choose
for example i didnt want the element so i skipped it
but that just leaves the equipButton's Once method intact
so since the equipButton wasnt clicked, its connection to its equip Function will remain listening, waiting for the user's input
until its clicked
so you should store the two button connections to their own variables
like
local skipConnection = skipButton.MouseButton1Click:Once(function() blabla end)
then disconnect those 2 connections with the :Disconnect() method after firing either of the button functions to make it stop listening for the signal from the user's input, so like:
skipConnection:Disconnect()
Okay, that makes sense I'll try that, thank you!
Would I put them within the functions themselves? I'm just a bit lost because if one comes before the other, it won't recognize that variable
yes yes
it will recognize it dw
just initialize the variables first before assigning the functions to them
Works perfect now! Ty a ton
like
local skipConnection
local equipConnection
skipConnection = skipButton.MouseButton1Click:Once(function()
--code yes
--Disconnect methods here in the end
end)
equipConnection = skipButton.MouseButton1Click:Once(function()
--code yes
--Disconnect methods here in the end
end)
noice
Just curious, what are those variables storing exactly?
The function itself?
@tribal timber sorry for the ping, just wasn't sure if you had closed it
o mb
well the event connections are being stored not the functions exactly