Hey, I am trying to make a point system but I get an error with the Datastore.
Error:
Script:
local DataStoreService = game:GetService("DataStoreService")
local PointsStore = DataStoreService:GetDataStore("PointSave")
game.Players.PlayerAdded:Connect(function(Player)
local SavedPoints = PointsStore:GetAsync(Player.UserId)
local Leaderstats = Instance.new("Folder", Player)
Leaderstats.Name = "leaderstats"
local PointsValue = Instance.new("IntValue", Leaderstats)
PointsValue.Name = "Points"
if SavedPoints ~= nil then
PointsValue.Value = SavedPoints
end
PointsValue.Changed:Connect(function(NewPoints)
PointsStore:SetAsync(Player.UserId, NewPoints)
end)
end)
It gives a point when you give a tool using a GUI, the script connected to that is:
game.ReplicatedStorage.GivePlayerItem.OnServerEvent:Connect(function(Player, PlayerName)
if Player.Name ~= PlayerName then
local ToolToGive = Player.Character:FindFirstChildWhichIsA("Tool")
ToolToGive.Parent = game.Players[PlayerName].Backpack
Player.leaderstats.Points.Value = Player.leaderstats.Points.Value + 1
end
end)
I hope anyone can help me, already thanks!