SaveInstance (Method): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
m Text replacement - "<SyntaxHighlight code="lua">" to "<syntaxhighlight lang="lua">"
m Text replacement - "</SyntaxHighlight>" to "</syntaxhighlight>"
 
Line 13: Line 13:
newPlayer:SaveInstance("Model", game.Workspace.Model)
newPlayer:SaveInstance("Model", game.Workspace.Model)
end)
end)
</SyntaxHighlight>
</syntaxhighlight>


The above example will save 'Model' ''(descendant of Workspace)'' to the player who enters the game. To access this instance again, we need to index it by it's key, 'Model' as defined in the first argument of this method.}}
The above example will save 'Model' ''(descendant of Workspace)'' to the player who enters the game. To access this instance again, we need to index it by it's key, 'Model' as defined in the first argument of this method.}}

Latest revision as of 05:18, 27 April 2023

SaveInstance( string key, RBX.lua.Instance (Object) value )
Returns nil
Description: Saves a Roblox instance, such as a part that can be reloaded on another server via LoadInstance. The DataComplexity used is the Object's DataCost property. Saving nil removes the entry and frees up DataComplexity units..
Member of: Player


Example
game.Players.PlayerAdded:connect(function(newPlayer)
	newPlayer:WaitForDataReady()
	newPlayer:SaveInstance("Model", game.Workspace.Model)
end)
The above example will save 'Model' (descendant of Workspace) to the player who enters the game. To access this instance again, we need to index it by it's key, 'Model' as defined in the first argument of this method.


See Also