Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What are Bindable Functions?

Asked by 9 years ago

I'm really puzzled by this topic. Bindable Function, I heard it once in a PeasPod video, but I really couldn't get any more information about it. I tried the ROBLOX wiki and some good scripters I know. I really don't know what it is, what's it's used for. I haven't asked a question in like 2 months. But I need this one answered, it may not help me in my future games, but the more the merrier.

Really hope I get a Good answer!

1 answer

Log in to vote
1
Answered by
Merely 2122 Moderation Voter Community Moderator
9 years ago

BindableFunctions are objects that have methods you can use to do communication between two scripts, or two localscripts.

For example, say you have an Admin Script, and a Cleanup Script. You want your admin script to tell your Cleanup script to remove everything in the Workspace.

You would create a BindableFunction in ServerStorage named "DoCleanup"

In the Cleanup Script:

local DoCleanup = Instance.new("BindableFunction")
DoCleanup.Name = "DoCleanup"
DoCleanup.Parent = game.ServerStorage

DoCleanup.OnInvoke = function()
    print("A script told me to clean up")
    game.Workspace:ClearAllChildren()
end

In the Admin Script:

local DoCleanup= game.ServerStorage:WaitForChild("DoCleanup")
wait(10)
DoCleanup:Invoke() -- call the BindableFunction

Often with BindableFunctions you would pass in parameters and get a return value. For the sake of simplicity I left that out. For example, a use case could be that you have a PointsSystem script that manages all points, and you want to get the number of points of a particular player from a script that's in a model in Workspace. You would create a BindableFunction and call it with the player as the first argument, and the PointsSystem script would return the number of points to you.

Basically, they're useful if you have complicated systems set up with multiple server side scripts needing to communicate with each other.

You can find more information on the wiki: http://wiki.roblox.com/index.php?title=BindableFunction

Ad

Answer this question