im trying to make it so when u have 1000 xp you hit level 1 but when u get 2257 you get to level 2 idk how id script that in my current leaderboard script anyone know to how with my script? CURRENT SCRIPT NEED FIXING
local level = game:GetService("DataStoreService"):GetDataStore("Levels")
local Xp = game:GetService("DataStoreService"):GetDataStore("Xp")
local axp = game:GetService("DataStoreService"):GetDataStore("AXP")
local RequiredXP = {
[0] = 1000,
[1] = 2257
}
function savedata(dataname, playerid)
game:GetService("DataStoreService"):GetDataStore(dataname):SetAsync(playerid, Value)
end
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder")
leader.Name = "leaderstats"
leader.Parent = player
local levels = Instance.new("IntValue")
levels.Value = level:GetAsync(tostring(player.userId)) or 1
levels.Name = "Level"
levels.Parent = player:WaitForChild("leaderstats")
local Xpz = Instance.new("NumberValue")
Xpz.Value = Xp:GetAsync(tostring(player.userId))
Xpz.Name = "Xp"
Xpz.Parent = player
local xpn = Instance.new("IntValue")
xpn.Value = axp:GetAsync(tostring(player.userId))or 1000
xpn.Name = "XpNeeded"
xpn.Parent = player
Xpz.Changed:connect(function()
if player:WaitForChild("Xp").Value >= player:WaitForChild("XpNeeded").Value then
levels.Value = levels.Value+1
xpn.Value = RequiredXP[levels.Value]
savedata("levels",player.userId.levels.Value)
savedata("Xp",player.userId.Axp.Value)
savedata("Axp",player.userId.xpn.Value)
else
savedata("levels",player.userId.levels.Value)
savedata("Xp",player.userId.Axp.Value)
savedata("Axp",player.userId.xpn.Value)
end
end)
end)

9 comments
@Decemus im so confused at where to add this script and how to change my script for this, Im new to this lua script stuff, i used to make websites using c# so i dont understand how to do half these lua scripts so could you edit my code to how it should be?
Did you make this script yourself?
scratch that dopshoesss made like 100% of it he just told me what to type and explained it to me while i typed it ;-; so i didnt make it but i consider i did cause i atleast typed it lol
Do you understand how it works?
Dammit, don't just hardcode the experience curve in. Write a function that will build it at runtime instead.
Decemus i really am pretty sure that i messed it up badly i changed it and idk how to fix it i did what you said
i just posted the current script and i have no idea what the error is
You switched the wrong line. I was referring to line 34.
switched it and its still broken