SaveString (Method): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Nickardson Added information about how SaveString handles an empty string, reducing DataCost. |
m Text replacement - "<SyntaxHighlight code="lua">" to "<syntaxhighlight lang="lua">" |
||
(12 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
<onlyinclude>{{ | <onlyinclude>{{Method | ||
|name = SaveString | |name = SaveString | ||
|arguments = | |arguments = {{type|string}} <var>key</var>, {{type|string}} <var>value</var> | ||
|description = Saves a | |description = Saves a {{type|string}} that can be reloaded from any server via [[LoadString (Method)|LoadString]]. The DataCost used by a saved string can be removed by saving an empty string ("") as the value. | ||
|object = Player | |object = Player | ||
}}</onlyinclude> | }}</onlyinclude> | ||
{{clear floats}} | {{clear floats}}<br /> | ||
==Example== | |||
This code will save "Hi Player" when the player leaves the game. | |||
<syntaxhighlight lang="lua"> | |||
game.Players.PlayerRemoving:connect(function(player) --Connection line. Fires when a player leaves the game. | |||
player:WaitForDataReady() --Waiting for the players data to be ready. | |||
player:SaveString("hi", "Hi Player")--When you load a string using this key, it will say "Hi Player" | |||
end | |||
end) | |||
</syntaxhighlight> | |||
==See Also== | |||
*[[File:Method Icon.png]] [[SaveBoolean (Method)|SaveBoolean]] | |||
*[[File:Method Icon.png]] [[SaveNumber (Method)|SaveNumber]] | |||
*[[File:Method Icon.png]] [[SaveInstance (Method)|SaveInstance]] | |||
[[Category:Methods]] | [[Category:Methods]] |
Latest revision as of 06:03, 27 April 2023
SaveString( string key, string value ) | |
Returns | nil |
Description: | Saves a string that can be reloaded from any server via LoadString. The DataCost used by a saved string can be removed by saving an empty string ("") as the value. |
Member of: | Player |
Example
This code will save "Hi Player" when the player leaves the game.
game.Players.PlayerRemoving:connect(function(player) --Connection line. Fires when a player leaves the game.
player:WaitForDataReady() --Waiting for the players data to be ready.
player:SaveString("hi", "Hi Player")--When you load a string using this key, it will say "Hi Player"
end
end)