My remote event variables are not overriding instead, they are becoming a table. If anyone can help fix this or provide me an alternative way to do the shown that would be appreciated!
https://gyazo.com/44af6c70e8058d35dd49e12672394cc8
Code:
https://gyazo.com/4288121412fb94fa4d689f0c1930fd1a
This is probably because you connect a new MouseButton1Click
event everytime the pop
function is called.
Instead of :Connect
ing something to MouseButton1Click
await for the event to be fired.
TextButton.MouseButton1Click:Wait()
RemoteEvent:FireServer(dcl, txt)
Connections do not automatically disappear. Using Connect() will create a permanent connection to the event until the script or object is deleted or you call Disconnect(). Also for the above solution, :Wait() does not time out or cancel so it doesnt make sense in a case with 2 buttons imo.
So the wait function would block me from pressing the other button? How could I use this same logic but apply it to two buttons?
Not entirely. It really depends how how you set everything up. The issue Wunder referenced above can occur:
Perhaps you should do what Wunder suggested.
When pop
is called disconnect all existing connections, and then connect your new one.
Usually when I make my GUIs, I make my own API so that it makes it very easy for my scripts and frameworks to interact with it without having to do the lower level stuff, but usually, I end up making some sort of State value. This makes it easy to manage what action to take when as I can just change the State
and have a click function do something different for the same button. Could work in your case assuming its the same exact dialog gui being prompted. Essentially, you could just leave the connections for the buttons on there forever and re-use them depending on the state value (or connect and disconnect).
??
Sorry, I do not quite get what you mean?
I don’t either, you are using a function as a function and then later trying to use it like it is a connection…?
That is the parameter that leads to Decal one.
Can you elaborate on that? Not sure what you’re trying to say…
If i make a function
local function bob()
end
then i can use
bob()
but in your code you are doing
bob:Disconnect()
why…? why are you trying to disconnect a function? That doesn’t make sense
Set whatever you are connecting to as a variable so you can then disconnect after
no… you asked why your remove event variables return a table
What I said minutes ago was my result of this. They told me the solution to this was disconnecting the function after it’s used more than once (decs), hence I’m trying to figure out how to format this.
I never said to disconnect a function. I said connections
.
Event:Connect(func) returns an object, a RBXScriptConnection
object
If I set it to a variable it just gives me an error line under pop1:Disconnect()
This is semi-obvious but that is because pop1
doesnt exist yet (AND AGAIN, you disconnect the CONNECTION, not the function)
in
local f = function() ... end
the first thing it does is create the function, THEN it makes the local
in this case, f would not exist before the function is created
two solutions / alternatives:
local f
f = function() ... end
or
local function f() ... end