so i have posted other post with a free script but everyone didnt liked.
then i picked up the custom datastore and added MY LEVEL UP SYSTEM
but didnt worked
here goes the script:
local datastore = game:GetService("DataStoreService"):GetDataStore("GameStats")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
game.Players.PlayerAdded:Connect(function(Plr)
local leaderstats = Instance.new("IntValue")
leaderstats.Name = "leaderstats"
leaderstats.Parent = Plr
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Value = 1
Level.Parent = leaderstats
local XP = Instance.new("IntValue")
XP.Name = "XP"
XP.Value = 0
XP.Parent = leaderstats
local Rank = Instance.new("StringValue")
Rank.Name = "Rank"
Rank.Value = "Genin"
Rank.Parent = leaderstats
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 10
Coins.Parent = leaderstats
local FC = Instance.new("IntValue")
FC.Name = "FC"
FC.Value = 100
FC.Parent = leaderstats
local key = "user-" .. Plr.userId
local storeditems = datastore:GetAsync(key)
if storeditems then
Level.Value = storeditems[1]
Rank.Value = storeditems[2]
XP.Value = storeditems[3]
Coins.Value = storeditems[4]
FC.Value = storeditems[5]
else
local items = {Level.Value, Rank.Value, XP.Value, FC.Value, Coins.Value} --Change Points or Wins if you changed line 10 or 14
datastore:SetAsync(key, items)
end
end)
game.ReplicatedStorage.AddXP.OnServerEvent:Connect(function(plr)
plr.leaderstats.XP.Value = plr.leaderstats.XP.Value + 50
end)
game.Players.PlayerAdded:Connect(function(plr)
wait(.1)
local XP = plr.leaderstats.XP
local Level = plr.leaderstats.Level
while wait() do
wait(.01)
if XP.Value >= (100 * (Level.Value + 1)) then
Level.Value = Level.Value + 1
XP.Value = 0
game.ReplicatedStorage.LevelUpGui:FireClient(plr)
end
end
end)
game.Players.PlayerRemoving:connect(function(player)
local items = {player.leaderstats.Level.Value, player.leaderstats.Rank.Value, player.leaderstats.XP.Value, player.leaderstats.Coins.Value, player.leaderstats.FC.Value} --Change Points or Wins if you changed line 10 or 14
local key = "user-" .. player.userId
datastore:SetAsync(key, items)
end)