write_script

Writes or fully overwrites a script's source.

What it does

write_script replaces the entire source of a script with new content. Revix uses it in two scenarios: writing the initial source for a script it just created with create_instance, and performing a genuine full rewrite when surgical edits would be more work than starting over.

For small, targeted changes Revix uses edit_script instead — overwriting an entire file just to change three lines makes the diff noisy and risks losing context Revix did not re-read. Because commands are processed by the plugin in queued order, a create_instance immediately followed by write_script is safe: the script will exist by the time the write runs.

Parameters

NameTypeRequiredDescription
`path`stringyesDataModel path to the script.
`source`stringyesFull Lua source code to write.

When Revix uses it

  • Right after create_instance to populate a brand-new script
  • When the existing script is so different from the target state that editing in place is harder than rewriting
  • When templated boilerplate (a RemoteEvent handler, a typical init.lua) is being dropped in for the first time

Example

lua
-- Path: ServerScriptService/GameManager
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
  print(player.Name .. " joined")
end)

Troubleshooting

If the script appears unchanged in Studio after a write, check that the plugin is connected and the path is correct. See editing scripts for the full workflow.