I have tried many websites and tutorials but none of them work or apply to my script. Roblox's dev hub page is confusing as I do not know what datastores are, can someone add saving and loading parts into my script?

--Variables
local Players = game:GetService("Players")
local DuckCoinName = "Quarcks"
local PointsName = "G. Points"
--Object Setup
local StatsOriginal = Instance.new("IntValue")
StatsOriginal.Name = "leaderstats"
local DuckCoinOriginal = Instance.new("NumberValue")
DuckCoinOriginal.Name = DuckCoinName
DuckCoinOriginal.Value = 0
DuckCoinOriginal.Parent = StatsOriginal
local PointsOriginal = Instance.new("NumberValue")
PointsOriginal.Name = PointsName
PointsOriginal.Value = 0
PointsOriginal.Parent = StatsOriginal
--Functions
local function PlayerAdded(player)
	local PlayerStats = StatsOriginal:Clone()
	local DuckCoins = Instance.new("NumberValue")
	DuckCoins.Name = "DuckCoins"
	DuckCoins.Value = 0
	DuckCoins.Parent = player
	local Points = Instance.new("NumberValue")
	Points.Name = "Points"
	Points.Value = 0
	Points.Parent = StatsOriginal
	local IsInEvent = Instance.new("BoolValue")
	IsInEvent.Name = "IsInEvent"
	IsInEvent.Value = false
	IsInEvent.Parent = player
	local CurrentEvent = Instance.new("StringValue")
	CurrentEvent.Name = "CurrentEvent"
	CurrentEvent.Value = ""
	CurrentEvent.Parent = player
	PlayerStats.Parent = player
	DuckCoins.Changed:Connect(function()
		PlayerStats:FindFirstChild(DuckCoinName).Value = DuckCoins.Value
	end)
	Points.Changed:Connect(function()
		PlayerStats:FindFirstChild(PointsName).Value = Points.Value
	end)
end
--Binds
Players.PlayerAdded:Connect(PlayerAdded)

There are three stats: Quarcks, G. Points and Points

2 comments

0

Did you try to allow API services?

0

I have tried allowing API services but data still does not save