I was messing around on studio for a bit and since I’m planning on recoding one of my games, I started scripting some bindable events. However, I ran into a problem; it seems that my bindable events aren’t returning anything. I tried firing an event that returned a boolean, but I instead received the “attempt to call a nil value” error.
Can bindable events return anything? If not, it’s a pretty weird limitation. Based on other posts, apparently this has been the case since 2016. If anyone can go into studio and try this out for themselves to confirm, that’d be pretty cool.
Events are one way communication, what you want is probably a BindableFunction. Bindable functions have an :Invoke() that is able to return a value through another script.
Script1:
local Bindable = ServerStorage.BindableFunction
Bindable.OnInvoke = function()
return "Hi"
end
Script 2:
local Bindable = ServerStorage.BindableFunction
local Value = Bindable:Invoke()
print(Value) --Prints Hi