I don't quite understand what the error is here?


local DataStore2 = require(game.ServerScriptService.DataModule) --Gets DataStore Module
local MainKey = "MainKey" -- The Key
DataStore2.Combine(MainKey,"Stats","Achievment")

--DataTable

local function SetDataTable()-- Setting Variables In A Table
	local UserData = {
		Stats = {
			["Kills"] = 0,
			["Deaths,"] = 0,
			["XP"] = 0,
			["Level"] = 1,
			["Coins"] = 0,
			
		},
		
		
	}
end


game.Players.PlayerAdded:Connect(function(plr) -- Does Function When Player Joins
	local UserData = DataStore2(MainKey,plr) --Gets Table
	
	local leaderstats = Instance.new("Folder") ---Leaderstats!--
	leaderstats.Name = "leaderstats"
	
	local kills = Instance.new("IntValue")
	kills.Name = "Kills"	
	
	local deaths = Instance.new("IntValue")
	deaths.Name = "Deaths"
	
	local xp = Instance.new("IntValue")
	xp.Name = "Xp"
	
	local xpn = Instance.new("IntValue")
	xpn.Name = "Xpn"
	
	local level = Instance.new("IntValue")
	level.Name = "Level"
	
	local coins = Instance.new("IntValue")
	coins.Name = "Coins"
	
	local gems = Instance.new("IntValue")
	gems.Name = "Gems"
	
	local StatsData = DataStore2("Stats",plr)
	
	local function UpdateStats(UpdatedValue) --Updates Data
		kills.Value = StatsData:Get(UpdatedValue).kills
		deaths.Value = StatsData:Get(UpdatedValue).deaths
		xp.Value = StatsData:Get(UpdatedValue).xp
		level.Value = StatsData:Get(UpdatedValue).level
		coins.Value = StatsData:Get(UpdatedValue).coins
		gems.Value = StatsData:Get(UpdatedValue).gems		
	end
	
	
	
	UpdateStats(UserData.Stats) -- updates data and calls the function
		
	StatsData:OnUpdate(UpdateStats) -- calls func on update
	
	--Parenting Properties
	leaderstats.Parent = plr
	kills.Parent = leaderstats
	deaths.Parent = leaderstats
	xp.Parent = leaderstats
	level.Parent = leaderstats
	coins.Parent = leaderstats
	gems.Parent = leaderstats
	
	--Giving Stats
	
	while true do
		wait(200)
		local KeyData = DataStore2(MainKey)
		KeyData:Save()
	end
	
	local function LevelUp()
		print("test")
	end
end)

2 comments

0

line error?

0

??