Skip to main content

Create your first script

Script file​

Lets create a new one, Press Q and go to Scripts, name it "TutScript" and hit Create it will generate a blank one in mods/scripts/

ProjectGWN/mods/scripts/TutScript/_init.luau
local mod = {speed = 100}

-- Will run after this file gets executed and it returns.
function mod:OnLoad()
-- note the : this will give you access to self.
print(self.speed) -- 100
end

-- Ticks every frame. Will never tick before OnLoad.
function mod:OnTick(deltaTime)
-- you can disable/enable it at a later time by editing the mod.OnTick = nil / yourFunction
end

-- Called when the script is restarted/unmounted.
function mod:OnUnload() end

return mod

Feel free to explore the full Scripting API