Run Function
Run Function is for the rare moment where a story needs trusted server code that VNC should not build into the core editor for everyone.
Use Insert > Scene & UI > Run Function when a built-in node cannot express the behavior. The node runs one ModuleScript from your server extension folder, then continues to Next unless the function reports a failure or asks to stop the story.
Properties
Node-specific properties
| Field | What it does |
|---|---|
| Function | Server function module to run. Use Create Module to scaffold one. |
| On Error | Whether failures continue the route or stop the story. |
Inherited/common properties
| Field | What it does |
|---|---|
| Name | Optional label used in the editor and Story Map. Leave it empty to use VNC's automatic node name. |
| Next | Node that runs after this node finishes its own work. |
Module Location
Run Function modules live under ServerScriptService.VisualNovelCreatorExtensions.Server.Functions.
The plugin also generates project-specific helpers under ServerScriptService.VisualNovelCreatorExtensions.Server.Generated.Story.
That generated module is what gives you IntelliSense for authored variables. Use Story.Variables for readable names and Story.VariablesById when the code should survive a variable rename.
--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")local Runtime = ReplicatedStorage:WaitForChild("VisualNovelCreatorRuntime")local Shared = Runtime:WaitForChild("Shared")local Contracts = require(Shared:WaitForChild("ExtensionContracts"))local Story = require(script.Parent.Parent.Generated.Story)
return function(context: Contracts.ServerFunctionContext): Contracts.FunctionResult? Story.Variables.PlayerName.set(context, "Bobo") local savedName = Story.VariablesById.playerName.get(context) context.log("Saved name: " .. tostring(savedName)) return { ok = true }endCompile after adding or renaming variables so the generated helper refreshes.
Results
| Return | Meaning |
|---|---|
nil | Treat as success and continue. |
{ ok = true } | Success; continue normally. |
{ ok = false, message = "..." } | Failure; follows the node's On Error setting. |
{ ok = true, stopStory = true } | Intentionally end the story now. |