LoadNumber (Method): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>SoulStealer9875
No edit summary
m Text replacement - "</SyntaxHighlight>" to "</syntaxhighlight>"
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<onlyinclude>{{AdminOnlyMethod
<onlyinclude>{{Method
|name                = LoadNumber
|name                = LoadNumber
|arguments            = [[String]] key
|arguments            = {{type|string}} <var>key</var>
|description          = Returns a number value that was previously saved to the player via [[SaveNumber (Method)|SaveNumber]] with the same key. If the key doesn't exist, it returns 0, not nil.
|description          = Returns a {{type|number}} value that was previously saved to the player via [[SaveNumber (Method)|SaveNumber]] with the same key. If the key doesn't exist, it returns 0, not nil.
|object              = Player
|object              = Player
|returns              = [[Number]] value
|returns              = {{type|number}}
}}</onlyinclude>
}}</onlyinclude>


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


<pre>
==Example==
game.Players.PlayerAdded:connect(function(newPlayer)
 
newPlayer:WaitForDataReady()
This code would print the number saved to the "Number" key of every player that enters.
p = newPlayer:LoadNumber("Number")
 
p.Parent = game.Workspace
<syntaxhighlight lang="lua">
game.Players.PlayerAdded:connect(function(player)
player:WaitForDataReady()
print(player:LoadNumber("Number"))
end)
end)
</pre>
</syntaxhighlight>
 
==See Also==
*[[File:Method Icon.png]] [[LoadBoolean (Method)|LoadBoolean]]
*[[File:Method Icon.png]] [[LoadString (Method)|LoadString]]
*[[File:Method Icon.png]] [[LoadInstance (Method)|LoadInstance]]


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

Latest revision as of 06:20, 27 April 2023

LoadNumber( string key )
Returns number
Description: Returns a number value that was previously saved to the player via SaveNumber with the same key. If the key doesn't exist, it returns 0, not nil.
Member of: Player


Example

This code would print the number saved to the "Number" key of every player that enters.

game.Players.PlayerAdded:connect(function(player)
	player:WaitForDataReady()
	print(player:LoadNumber("Number"))
end)

See Also