BindableEvent & BindableFunction won't do as intended

Hello, I am trying to write a test for something, and I’ve ran into a major problem that is holding me back currently.

When passing a userdata created using the newproxy function into a BindableEvent or BindableFunction, it is nil. Does anyone know any work-arounds for this? If so, please let me know. Here is my testing code to reproduce this:

local Event = Instance.new("BindableEvent",script)
Event.Name = "TestEvent"

local Callback = Instance.new("BindableFunction",script)
Callback.Name = "TestCallback"

Event.Event:Connect(function(Data)
	if Data == nil then
		warn("Data is nil!",Data,typeof(Data))
	else
		print(Data,typeof(Data))
	end	
end)

print("Event Test")

Event:Fire({Hello="World"}) --Not nil
Event:Fire(newproxy(true)) --Nil

Callback.OnInvoke = function(Data)
	if Data == nil then
		warn("Data is nil!",Data,typeof(Data))
	else
		print(Data,typeof(Data))
	end	
end

print("Callback Test")

Callback:Invoke({Hello="World"}) --Not nil
Callback:Invoke(newproxy(true)) --Nil

Output:
Nil

Userdata created with newproxy unfortunately cannot be sent over Bindables or Remotes. The later is more annoying to deal with, but the former can easily be solved by creating your own custom event classes; purely in Luau.

Some pretty good artificial signals have been posted on #resources:community-resources. So it’s worth looking around there if you don’t want to write your own implementation.

1 Like

Alright, thanks for the help. I’ll look into artificial signals.

1 Like