I can load and save my coins and gems, but I want to set "equippedGun" and "equippedKnife" to "Default" if they are new to my game. How would I do that? NOTE: this is ONLY if they are NEW to my game, not just everytime they join, so if they have played before it would do the one they had Here is what I have so far.
local DS1 = game:GetService("DataStoreService"):GetDataStore("Coins")
local DS2 = game:GetService("DataStoreService"):GetDataStore("Gems")
local DS3 = game:GetService("DataStoreService"):GetDataStore("equippedKnife")
local DS4 = game:GetService("DataStoreService"):GetDataStore("equippedGun")
game.Players.PlayerAdded:connect(function(player)
local stats = Instance.new("IntValue", player)
stats.Name = "leaderstats"
local coins = Instance.new("IntValue", stats)
coins.Name = "Coins"
coins.Value = DS1:GetAsync(player.UserId)
local gems = Instance.new("IntValue", stats)
gems.Name = "Gems"
gems.Value = DS2:GetAsync(player.UserId)
local inGame = Instance.new("BoolValue", player)
inGame.Name = "InGame"
local equippedKnife = Instance.new ("StringValue", player)
equippedKnife.Name = "equippedKnife"
equippedKnife.Value = "Default"
local equippedGun = Instance.new("StringValue", player)
equippedGun.Name = "equippedGun"
equippedGun.Value = "Default"
while wait(60) do
DS1:SetAsync(player.UserId.."_DS1", coins.Value)
print("Saved Coins")
--Saved Coins
DS2:SetAsync(player.UserId.."_DS2", gems.Value)
print ("Saved Gems")
--Saved Gems
DS3:SetAsync(player.UserId.."_DS3", equippedKnife.Value)
print ("Saved knifeEquipped")
--Saved equipped Knife
DS4:SetAsync(player.UserId.."_DS4", equippedGun.Value)
print ("Saved gunEquipped")
--Saved equipped Gun
end
end)

2 comments
Thanks! This is exactly what I was looking for! Since I am only a beginner scripter and have not learnt this stuff it is hard for me. Thanks again!
No problem.