16:12:44.883 - Points is not a valid member of Folder 16:12:44.884 - Stack Begin 16:12:44.884 - Script 'ServerScriptService.CurrencyScript', Line 31 16:12:44.884 - Stack End*
local replicatedStorage = game:GetService("ReplicatedStorage")
local shopItems = game:GetService("ServerStorage"):WaitForChild("ShopItems")
local currencyName = "Cash"
local DataStore = game:GetService("DataStoreService"):GetDataStore("TestDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local currency = Instance.new("IntValue")
currency.Name = "Cash"
currency.Parent = leaderstats
local ID = currencyName.."-"..player.UserId
local savedData = nil
pcall(function()
savedData = DataStore:GetAsync(ID)
end)
if savedData ~= nil then
currency.Value = savedData
print("Data Loaded")
else
--New Player
currency.Value = 0
print("New Player To The Game")
end
end)
replicatedStorage.GetInfo.OnServerInvoke = function(player,item)
return shopItems[item].currency.Value
end
game.Players.PlayerRemoving:Connect(function(player)
local ID = currencyName.."-"..player.UserId
DataStore:SetAsync(ID,player.leaderstats[currencyName].Value)
end)
game:BindToClose(function()
--When game is ready to shutdown
for i, player in pairs(game.Players:GetPlayers()) do
if player then
player:Kick("This game is shutting down")
end
end
wait(5)
end)

1 comment
I see now "Points" at line 31