SaveBoolean (Method): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>ArceusInator
example
m Text replacement - "</SyntaxHighlight>" to "</syntaxhighlight>"
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{AdminOnly}}
<onlyinclude>{{Method
<onlyinclude>{{AdminOnlyMethod
|name                = SaveBoolean
|name                = SaveBoolean
|arguments            = [[String]] key, [[Bool]] value
|arguments            = {{type|string}} <var>key</var>, {{type|bool}} <var>value</var>
|description          = Saves a boolean value that can be reloaded from any server via [[LoadBoolean (Method)|LoadBoolean]]
|description          = Saves a {{type|boolean}} value that can be reloaded from any server via [[LoadBoolean (Method)|LoadBoolean]].
|object              = Player
|object              = Player
|returns              = [[nil]]
}}</onlyinclude>
}}</onlyinclude>


{{clear floats}}
{{clear floats}}
{{Example|
This example will save true as the value of the key 'HasPlayed' everytime a player leaves.
<syntaxhighlight lang="lua">
game.Players.PlayerRemoving:connect(function(player)
if player.DataReady then -- To make sure the data is ready.
player:SaveBoolean('HasPlayed', true) -- Save the boolean.
end
end)
</syntaxhighlight>}}
==See Also==
*[[File:Method Icon.png]] [[SaveNumber (Method)|SaveNumber]]
*[[File:Method Icon.png]] [[SaveString (Method)|SaveString]]
*[[File:Method Icon.png]] [[SaveInstance (Method)|SaveInstance]]


[[Category:Methods]]
[[Category:Methods]]
{{Example|In one server...<pre>
game.Players.LocalPlayer:SaveBoolean( testBoolean, true )
</pre>
In another server...<pre>
print( game.Players.LocalPlayer:LoadBoolean( testBoolean ) ) --> true</pre>}}

Latest revision as of 04:59, 27 April 2023

SaveBoolean( string key, bool value )
Returns nil
Description: Saves a boolean value that can be reloaded from any server via LoadBoolean.
Member of: Player


Example

This example will save true as the value of the key 'HasPlayed' everytime a player leaves.

game.Players.PlayerRemoving:connect(function(player)
	if player.DataReady then -- To make sure the data is ready.
		player:SaveBoolean('HasPlayed', true) -- Save the boolean.
	end
end)


See Also