SaveNumber (Method): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>MrNicNac
No longer AdminOnly.
>JulienDethurens
No edit summary
Line 1: Line 1:
<onlyinclude>{{Method
<onlyinclude>{{Method
|name                = SaveNumber
|name                = SaveNumber
|arguments            = [[String]] key, [[Number]] value
|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]].  The [[DataCost]] taken up by a saved number can be removed by saving ''0'' as the value.
|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
|returns              = [[nil]]
}}</onlyinclude>
}}</onlyinclude>


{{clear floats}}
{{clear floats}}


<pre>
==Example==
game.Players.PlayerAdded:connect(function(newPlayer)
 
newPlayer:WaitForDataReady()
This code would save the {{type|number}} 5 to the key "Number" when a player leaves:
newPlayer:SaveNumber("Number", game.Workspace.Number.Value)
 
<code lua>
game.Players.PlayerAdded:connect(function(player)
player:WaitForDataReady()
player:SaveNumber("Number", 5)
end)
end)
</pre>
</code>


[[Category:Methods]]
[[Category:Methods]]

Revision as of 23:28, 12 February 2012

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.PlayerAdded:connect(function(player) player:WaitForDataReady() player:SaveNumber("Number", 5) end)