SaveNumber (Method): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Brandonhare Making testNumber a string |
m Text replacement - "<SyntaxHighlight code="lua">" to "<syntaxhighlight lang="lua">" Tags: mobile web edit mobile edit |
||
(26 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
<onlyinclude>{{Method | |||
<onlyinclude>{{ | |||
|name = SaveNumber | |name = SaveNumber | ||
|arguments = | |arguments = {{type|string}} <var>key</var>, {{type|float}} <var>value</var> | ||
|description = Saves a number value that can be reloaded from any server via [[LoadNumber (Method)|LoadNumber]] | |description = Saves a {{type|number}} value that can be reloaded from any server via [[LoadNumber (Method)|LoadNumber]]. The [[DataCost]] taken up by a saved {{type|number}} can be removed by saving ''0'' as the value. | ||
|object = Player | |object = Player | ||
}}</onlyinclude> | }}</onlyinclude> | ||
{{clear floats}} | {{clear floats}} | ||
==Example== | |||
This code would save the {{type|number}} 5 to the key "Number" when a player leaves: | |||
<syntaxhighlight lang="lua"> | |||
game.Players.PlayerRemoving:connect(function(player) | |||
if player.DataReady then | |||
player:SaveNumber("Number", 5) | |||
end | |||
end) | |||
</syntaxhighlight> | |||
==See Also== | |||
*[[File:Method Icon.png]] [[SaveBoolean (Method)|SaveBoolean]] | |||
*[[File:Method Icon.png]] [[SaveString (Method)|SaveString]] | |||
*[[File:Method Icon.png]] [[SaveInstance (Method)|SaveInstance]] | |||
[[Category:Methods]] | [[Category:Methods]] | ||
Latest revision as of 05:27, 27 April 2023
SaveNumber( string key, float value ) | |
Returns | nil |
Description: | Saves a number value that can be reloaded from any server via LoadNumber. The DataCost taken up by a saved number can be removed by saving 0 as the value. |
Member of: | Player |
Example
This code would save the number 5 to the key "Number" when a player leaves:
game.Players.PlayerRemoving:connect(function(player)
if player.DataReady then
player:SaveNumber("Number", 5)
end
end)