Script
An object that contains and runs Lua code on the server.
Memory category | Script |
---|
Member index 2
Description
A Script is a Lua code container that can access server-side objects, properties, and events, such as to award badges to players using BadgeService, while LocalScripts on the client cannot.
The instant that the following conditions are met, a script's code is run in a new thread:
- Its Enabled property is
true
. - The Script object is a descendant of the Workspace or ServerScriptService.
The script will continue to run until the above conditions are not met, it
terminates, or it raises an error (unless that error is raised by a function
connected to some event that is firing). Additionally, the thread will be
stopped if the script or one of its ancestors is destroyed. A script will
continue to run even if the Parent property is set to
nil
and the Script is not destroyed.
History 13
- 645 Change WriteSecurity of Source from PluginSecurity to None
- 645 Change ReadSecurity of Source from PluginSecurity to None
- 486 Change ThreadSafety of Source from ReadOnly to ReadSafe
- 462 Change ThreadSafety of GetHash from to Unsafe
- 462 Change ThreadSafety of Source from to ReadOnly
- 311 Change Security of GetHash from RobloxPlaceSecurity to LocalUserSecurity
- 151 Change WriteSecurity of Source from security1 to PluginSecurity
- 151 Change ReadSecurity of Source from security1 to PluginSecurity
- 150 Change WriteSecurity of Source from LocalUserSecurity to security1
- 150 Change ReadSecurity of Source from LocalUserSecurity to security1
- 47 Add GetHash
- 47 Add Source
- 47 Add Script
Members 2
GetHash
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
string |
Security | LocalUserSecurity |
---|---|
Thread safety | Unsafe |
Source
Type | Default | |
---|---|---|
ProtectedString |
Represents the code to be executed. It's protected and discouraged for editing directly. Attempting to access this property in a Script or LocalScript causes errors.
If you want to read or modify the source of a script that a user has open, use ScriptEditorService to interact with the Script Editor rather than directly modifying this property. Both ScriptEditorService:UpdateSourceAsync() and ScriptEditorService:GetEditorSource() can read or modify script content from the script editor if the script is opened. You can also read the source from the command line.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
History 9
- 645 Change WriteSecurity of Source from PluginSecurity to None
- 645 Change ReadSecurity of Source from PluginSecurity to None
- 486 Change ThreadSafety of Source from ReadOnly to ReadSafe
- 462 Change ThreadSafety of Source from to ReadOnly
- 151 Change WriteSecurity of Source from security1 to PluginSecurity
- 151 Change ReadSecurity of Source from security1 to PluginSecurity
- 150 Change WriteSecurity of Source from LocalUserSecurity to security1
- 150 Change ReadSecurity of Source from LocalUserSecurity to security1
- 47 Add Source