How can I send this Data to a BindableEvent using a 'self' function?

So I’m trying to Send a Piece of Data using a BindableFunction using OOP, but I cant seem to figure out how, as I have tried creating a function like this:

self.SendData = function()
    return MapData
end

And Setting the Function to the BindableEvent:

function Mod:SetDataOnInvoke()
    print(MapData)
    SendData.OnInvoke = self.SendData
end

But This doesnt work at all.

SendData:Invoke() -- no errors, but nothing happens

What Should I do?

Do you mean BindableFunction?

Also, what is MapData? Is it the event returned by SendData? If so, you need to do: SendData():Invoke().

there’s not much I can understand from this, try calling SendData

Whoops.

Its a Table:

MapData = {
    Name       = map.Name,
    BGM        = map.Settings.BGM.Value
    Difficulty = math.clamp(map.Settings.Difficulty.Value, 1, #DifficultyData)
}

Nope, I added a Print inside it to check, it doesnt print, however I forgot to Include the print for the Topic.

No, Because Im trying to add the function to the BindableFunction so it can be fired from there.

Do you mean this one doesn’t print?

they meant inside the SendData function

1 Like

No, I meant this one, which was where I forgot to put print()

does SendData get assigned at instancing? (when calling the constructor)

We need more info of this problem. whats senddata?

a function that returns a MapData array

not self.SendData. Just senddata

I just tested the same setup and it works for me, so it’s either some other factor or you not calling that method

apparently it’s a BindableEvent

is the MapData array a global object? :face_with_raised_eyebrow: @DasKairo

Yeah, I made sure to test with another Map, and yes, its working, so its likely something else.

I meant to say BindableFunction, that was my bad.

Yes, Because if I add it to self, it would just overcomplicate things that I have with my code.

nah my bad I meant to write bindablefunction. what if there’s some yielding in the mapdata array values? have you tried calling other functions?

but no that wouldn’t make sense since you’re not calling waitforchild. idrk

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.