SaveString (Method): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>JulienDethurens
No edit summary
m Text replacement - "<SyntaxHighlight code="lua">" to "<syntaxhighlight lang="lua">"
 
(8 intermediate revisions by 3 users not shown)
Line 6: Line 6:
}}</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==
==See Also==

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)

See Also