LoadString (Method): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Itunes89 No edit summary |
m Text replacement - "<SyntaxHighlight code="lua">" to "<syntaxhighlight lang="lua">" Tags: mobile web edit mobile edit |
||
(10 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<onlyinclude>{{Method | <onlyinclude>{{Method | ||
|name = | |name = LoadString | ||
|arguments = {{type|string}} <var>key</var> | |arguments = {{type|string}} <var>key</var> | ||
|description = Returns a | |description = Returns a {{type|string}} value that was previously saved to the player via [[SaveString (Method)|SaveString]] with the same key. Returns an empty {{type|string}} ("") if key doesn't exist, not nil. | ||
|object = | |object = Player | ||
|returns = {{type|string}} | |returns = {{type|string}} | ||
}}</onlyinclude> | }}</onlyinclude> | ||
Line 9: | Line 9: | ||
{{clear floats}} | {{clear floats}} | ||
<br /> | <br /> | ||
==Example== | |||
This code will load the string saved under the key "hi". | |||
<syntaxhighlight lang="lua"> | |||
game.Players.PlayerAdded:connect(function(player) --Connection line. Fires when a player leaves the game. | |||
player:WaitForDataReady() --Waiting for the player's data to be ready. | |||
print(player:LoadString("hi")) --Prints to the output whatever value is saved to the key "hi" in that player. | |||
end | |||
end) | |||
</syntaxhighlight> | |||
==See Also== | |||
*[[File:Method Icon.png]] [[LoadBoolean (Method)|LoadBoolean]] | |||
*[[File:Method Icon.png]] [[LoadNumber (Method)|LoadNumber]] | |||
*[[File:Method Icon.png]] [[LoadInstance (Method)|LoadInstance]] | |||
[[Category:Methods]] |
Latest revision as of 06:04, 27 April 2023
LoadString( string key ) | |
Returns | string |
Description: | Returns a string value that was previously saved to the player via SaveString with the same key. Returns an empty string ("") if key doesn't exist, not nil. |
Member of: | Player |
Example
This code will load the string saved under the key "hi".
game.Players.PlayerAdded:connect(function(player) --Connection line. Fires when a player leaves the game.
player:WaitForDataReady() --Waiting for the player's data to be ready.
print(player:LoadString("hi")) --Prints to the output whatever value is saved to the key "hi" in that player.
end
end)