local dataservice = game:GetService('DataStoreService'):GetDataStore("example")
game.Players.PlayerAdded:connect(function(player)
----------------------------------------------------------------
local ukey = 'id-'..player.userId
local titanium = Instance.new('IntValue') --- Store titanium
local resources = Instance.new('Folder',player)
resources.Name = 'Resources'
titanium.Parent = resources
titanium.Name = 'Titanium'
local GetSaved = dataservice:GetAsync(ukey)
if GetSaved then
titanium.Value = GetSaved[1]
if titanium.Value ~= 0 then
game.Lighting.Items.Titanium:Clone().Parent = player:WaitForChild("PlayerStorage")
player.PlayerStorage.Titanium.Quantity.Value = titanium.Value
end
else
local NumberForSaving = {titanium.Value}
dataservice:SetAsync(ukey, NumberForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(player)
local ukey = 'id-'..player.userId
local savedtbl = {player.Resources.Titanium.Value}
dataservice:SetAsync(ukey, savedtbl)
end)
The script above It's my datastore script obviously... what i'm trying to do is when a player who joined the game titanium value does not equal to 0 a part from lighting will be clone to the player instance folder called "resources". so anyone who joined the game as long as their titanium value does not equal to 0 it will clone the part...
THE PROBLEM
If a player is new to the game and of course the player titanium value is 0 because the player hasn't played yet meaning the the part will not be cloned.. since the player titanium value is 0. Now if the player during the game gathered a titanium using a tool inside the tool i have a script which will add a value to the player titanium
Player.Resources.Titanium.Value = Player.Resources.Titanium.Value +5
Like that^, now i want to make it clone the part because the player titanium value is no longer equal to 0 and i want to clone the part only once just like when a player joins the game.

2 comments
Does this need to be done through a data store? When and where does the titanium value change?
You also should not be using lighting to store object, use server storage or rep storage.