You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Registers a script file that will be downloaded and used client-side.
Calling this function is required for every client script.
If no parameter is set, this function registers the script file from where it's called.
Prototype:
RegisterClientScript([filepath: string])
Parameters:
filepath: Path to the script (relative to the scripts directory).
Remarks:
All calls to RegisterClientScript should be done at initialization, before any player joins.
Only server-registered scripts can be included client-side. If a client script tries to include a non-registered script file it will not be found by the game (independently of the file existence on the dive).
The server and map editor don't have this restriction.
This function exists client-side only for convenience and does nothing when called, as it's commonly called in shared element scripts.
Example code
A simple shared.lua entity using a custom asset
-- Registers the script client-sideRegisterClientScript()
-- Registers box.png as a client-side assetRegisterClientAssets("box.png")
if (CLIENT) thenentity:On("init", function (self)
self:AddSprite({
-- Using the assetTexturePath="box.png"
})
end)
end