ProtectedString: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>ArceusInator
New page: === Introduction === ---- A ProtectedString is a data type that imitates the behavior of a String while still being very differrent. This type of String is niether readable or...
>Blocco
Proofread your work, please. Unable to spell a word properly? Use a homonym.
Line 1: Line 1:
=== Introduction ===
=== Introduction ===
----
----
A [[ProtectedString]] is a data type that imitates the behavior of a [[String]] while still being very differrent.  This type of [[String]] is niether readable or writable from [[Script]]s.  Here, I will use the [[Script]]'s [[Source (Property)|Source]] property to demonstrate what would happen if you were to attempt to manipulate a [[ProtectedString]].
A [[ProtectedString]] is a data type that imitates the behavior of a [[String]] while still being very differrent.  This type of [[String]] is neither readable or writable from [[Script]]s.  Here, I will use the [[Script]]'s [[Source (Property)|Source]] property to demonstrate what would happen if you were to attempt to manipulate a [[ProtectedString]].


<pre>
<pre>
Line 21: Line 21:
Workspace.Script.Source = [[print("Hello, World!")]]</pre>
Workspace.Script.Source = [[print("Hello, World!")]]</pre>


Unfortunately, we find that this does not work.  There is only one way to set the Source property and it is as follows:
Unfortunately, this does not work.  There is only one way to set the Source property and it is as follows:


<pre>
<pre>

Revision as of 21:24, 11 January 2011

Introduction


A ProtectedString is a data type that imitates the behavior of a String while still being very differrent. This type of String is neither readable or writable from Scripts. Here, I will use the Script's Source property to demonstrate what would happen if you were to attempt to manipulate a ProtectedString.

print( Workspace.Script.Source )

This would call an error saying that Source is not a valid member of Script. This is because the script you are using doesn't recognize Script.Source. It won't recognize any other ProtectedString value either.

There is no way to create a ProtectedString value.



Getting around Script.Source


This is a major obstacle that gets in the way of many scripters all around Roblox. It's the problem of setting a Script's Source. Many scripters will try to set Script.Source the conventional way:

Workspace.Script.Source = [[print("Hello, World!")]]

Unfortunately, this does not work. There is only one way to set the Source property and it is as follows:

HIERARCHY:

Workspace
-Script   [Disabled = true]
--SourceCode   [className = StringValue]

Workspace.Script's source:

assert( loadstring( script.SourceCode.Value ) )()

Your script's source:

Workspace.Script.SourceCode.Value = [[print("Hello, World!")]]

Workspace.Script.Disabled = false -- this runs the script

--> Hello, World!