RobloxLocked (Property): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
m Text replacement - "<code lua>" to "<SyntaxHighlight code="lua">"
m Text replacement - "</code>" to "</SyntaxHighlight>"
Line 12: Line 12:


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




Line 22: Line 22:
Workspace.Part.RobloxLocked = true
Workspace.Part.RobloxLocked = true


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


script.Parent = game.CoreGui --> Unknown exception
script.Parent = game.CoreGui --> Unknown exception
--Errors because CoreGui has RobloxLocked set to true by default</code>}}
--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 is 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]]:<SyntaxHighlight code="lua">
{{Example|[[Script]]:<SyntaxHighlight code="lua">
game.CoreGui.RobloxGui:Destroy() -- nope</code>
game.CoreGui.RobloxGui:Destroy() -- nope</SyntaxHighlight>
[[Command Bar]]:<SyntaxHighlight code="lua">
[[Command Bar]]:<SyntaxHighlight code="lua">
game.CoreGui.RobloxGui.RobloxLocked = false</code>
game.CoreGui.RobloxGui.RobloxLocked = false</SyntaxHighlight>
[[Script]]:<SyntaxHighlight code="lua">
[[Script]]:<SyntaxHighlight code="lua">
game.CoreGui.RobloxGui:Destroy() -- still no</code>
game.CoreGui.RobloxGui:Destroy() -- still no</SyntaxHighlight>
[[Command Bar]]:<SyntaxHighlight code="lua">
[[Command Bar]]:<SyntaxHighlight code="lua">
game.CoreGui.RobloxLocked = false</code>
game.CoreGui.RobloxLocked = false</SyntaxHighlight>
[[Script]]:<SyntaxHighlight code="lua">
[[Script]]:<SyntaxHighlight code="lua">
game.CoreGui.RobloxGui:Destroy() -- Yes!</code>}}
game.CoreGui.RobloxGui:Destroy() -- Yes!</SyntaxHighlight>}}


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

Revision as of 03:16, 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!