I am currently trying to make a Skin Shop GUI that also saves. What i dont know to do is make the player have the skin if he owns it and also, how i said, to save it. You can buy a skin with coins.
Here is my coins script:
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder")
stats.Name = "stats"
stats.Parent = player
local coins = Instance.new("NumberValue")
coins.Name = "Coins"
coins.Parent = stats
coins.Value = 0
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(player.UserId.."-coins")
end)
if success then
coins.Value = data
else
print("There was an error whilst getting your data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-coins",player.stats.Coins.Value)
end)
if success then
print("Coins successfully saved")
else
print("Error while saving coins")
warn(errormessage)
end
end)
I am trying to do this for like 3 months!
