I am having some trouble with this script (by the way I didn't do this script I copyed it from a youtuber called (AlvinBlox) when ever I launch the game and I look at the output it pops up with Points is not a valid member of folder
Here is the script (it is a currency script that also saves your data)
local CurrencyName = "Points" -- Here is the currencys name
local DataStore = game:GetService("DataStoreService"):GetDataStore("DataSaver")
game.Players.PlayerAdded:Connect(function(player) -- When a player is added to Players
local folder = Instance.new("Folder") -- Putting a folder into the player that joined Players
folder.Name = "leaderstats" -- Folders name
folder.Parent = player -- The folders parent = player
local currency = Instance.new("IntValue") -- currency that has a IntValue to it
currency.Name = CurrencyName -- The name of the currency(its at the top of the script)
currency.Parent = folder -- The currencys parent =folder
local ID = CurrencyName.."-"..player.UserId -- players Id
local savedData = nil
pcall(function()
savedData = DataStore:GetAsync(ID)
end)
if savedData ~= nil then
currency.Value = savedData
print("Data Loaded!")
else
-- New Player Currency Only
currency.Value = 50
print("New Player To The Game")
end
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 server is shutting down")
end
end
wait(5)
end)
If anyone could help me that would be great (Its a normal script not a local, the script is in ServerScriptService)

4 comments
I don't know what I'm doing wrong
What line is the error on?
I will have a look
09:54:48.733 - Points is not a valid member of Folder (it's not telling me what line it it on)