RobloxLocked (Property): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Blocco
Simpler?
m Text replacement - "</SyntaxHighlight>" to "</syntaxhighlight>"
 
(18 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{CatUp|Properties}}
{{protected}}


<onlyinclude>{{Property
<onlyinclude>{{Property
|name        = RobloxLocked
|name        = RobloxLocked
|property    = [[Bool]] ''RobloxLocked''
|protected  = yes
|description = Sets whether the object and its descendants can be indexed or edited by code with a security context level below 4<!--[[Script]]s or [[LocalScript]]s-->.
|type = {{type|bool}}
|description = If true, the object and its descendants cannot be indexed or edited by a [[Script]] or [[LocalScript]] and will throw an error if it is attempted.
|object      = Instance
|object      = Instance
}}</onlyinclude>
}}</onlyinclude>


{{clear floats}}


 
{{Example|If using the [[Command Bar|command bar]] or a [[CoreScript]]...<syntaxhighlight lang="lua">
 
Workspace.Part.RobloxLocked = true -- sets the Part's RobloxLocked to true</syntaxhighlight>
 
If using a [[Script]] or [[LocalScript]]...<syntaxhighlight lang="lua">
 
Workspace.Part.RobloxLocked = true --> Unknown exception</syntaxhighlight>}}
 
 
 
 
 
 
 
 
{{Example|If using the [[Command Bar]] or a [[CoreScript]]...<pre>
game.Workspace.Part.RobloxLocked = true -- sets the Part's RobloxLocked to true</pre>
If using a [[Script]] or [[LocalScript]]...<pre>
game.Workspace.Part.RobloxLocked = true --> s RobloxLocked</pre>}}




==RobloxLocked doesn't get saved==
==RobloxLocked doesn't get saved==
Therefore, you can set an object's [[RobloxLocked (Property)|RobloxLocked]] to true, but unless you found some way to do that with a [[CoreScript]] at the start of the game, you will still be able to access the object from a [[Script]] or [[LocalScript]].
Therefore, you can set an object's [[RobloxLocked (Property)|RobloxLocked]] property to true, but unless you found some way to do that with a [[CoreScript]] at the start of the game, you will still be able to access the object from a [[Script]] or [[LocalScript]]. There are, however, some objects that are RobloxLocked by default.
{{Example|[[Command Bar]]:<pre>
{{Example|[[Command Bar]]:<syntaxhighlight lang="lua">
Workspace.Part.RobloxLocked = true
Workspace.Part.RobloxLocked = true


print( Workspace.Part.RobloxLocked ) --> true</pre>
print( Workspace.Part.RobloxLocked ) --> true</syntaxhighlight>
[[Script]]:<pre>
[[Script]]:<syntaxhighlight lang="lua">
script.Parent = Workspace.Part -- works because RobloxLocked was no default true
script.Parent = Workspace.Part -- does not error because RobloxLocked is false by default for this object


script.Parent = game.CoreGui --> s Parent</pre>}}
script.Parent = game.CoreGui --> Unknown exception
--Errors because CoreGui has RobloxLocked set to true by default</syntaxhighlight>}}


==RobloxLocked-ness is inherited==
==RobloxLocked-ness is inherited==
This means that if Workspace.RobloxLocked==true, then everything in the Workspace will act as if it was RobloxLocked.
This means that if Workspace.RobloxLocked is true, then everything in the Workspace will act as if it was RobloxLocked.
{{Example|[[Script]]:<pre>
{{Example|[[Script]]:<syntaxhighlight lang="lua">
game.CoreGui.RobloxGui:remove() -- nope</pre>
game.CoreGui.RobloxGui:Destroy() -- nope</syntaxhighlight>
[[Command Bar]]:<pre>
[[Command Bar]]:<syntaxhighlight lang="lua">
game.CoreGui.RobloxGui.RobloxLocked = false</pre>
game.CoreGui.RobloxGui.RobloxLocked = false</syntaxhighlight>
[[Script]]:<pre>
[[Script]]:<syntaxhighlight lang="lua">
game.CoreGui.RobloxGui:remove() -- still no</pre>
game.CoreGui.RobloxGui:Destroy() -- still no</syntaxhighlight>
[[Command Bar]]:<pre>
[[Command Bar]]:<syntaxhighlight lang="lua">
game.CoreGui.RobloxLocked = false</pre>
game.CoreGui.RobloxLocked = false</syntaxhighlight>
[[Script]]:<pre>
[[Script]]:<syntaxhighlight lang="lua">
game.CoreGui.RobloxGui:remove() -- Yes!</pre>}}
game.CoreGui.RobloxGui:Destroy() -- Yes!</syntaxhighlight>}}


[[Category:Properties]]
[[Category:Properties]]

Latest revision as of 06:17, 27 April 2023

Protected:This item is protected. Attempting to use it in a Script or LocalScript will cause an error.
RobloxLocked
Type bool
Description If true, the object and its descendants cannot be indexed or edited by a Script or LocalScript and will throw an error if it is attempted.
Member of Instance


Example
If using the command bar or a CoreScript...
Workspace.Part.RobloxLocked = true -- sets the Part's RobloxLocked to true
If using a Script or LocalScript...
Workspace.Part.RobloxLocked = true --> Unknown exception


RobloxLocked doesn't get saved

Therefore, you can set an object's RobloxLocked property to true, but unless you found some way to do that with a CoreScript at the start of the game, you will still be able to access the object from a Script or LocalScript. There are, however, some objects that are RobloxLocked by default.

Example
Command Bar:
Workspace.Part.RobloxLocked = true

print( Workspace.Part.RobloxLocked ) --> true
Script:
script.Parent = Workspace.Part -- does not error because RobloxLocked is false by default for this object

script.Parent = game.CoreGui --> Unknown exception
--Errors because CoreGui has RobloxLocked set to true by default


RobloxLocked-ness is inherited

This means that if Workspace.RobloxLocked is true, then everything in the Workspace will act as if it was RobloxLocked.

Example
Script:
game.CoreGui.RobloxGui:Destroy() -- nope
Command Bar:
game.CoreGui.RobloxGui.RobloxLocked = false
Script:
game.CoreGui.RobloxGui:Destroy() -- still no
Command Bar:
game.CoreGui.RobloxLocked = false
Script:
game.CoreGui.RobloxGui:Destroy() -- Yes!