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
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)
Change line 34 from:
DataStore:SetAsync(ID,player.leaderstats(CurrencyName).Value)
to:
DataStore:SetAsync(ID,player.leaderstats[CurrencyName].Value)
You were using parentheses which are used for function calls. Replacing these with brackets will fix the issue, as these are used for indexing.