Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

leaderboard different amount of xp to level up to certian levels? [NOT ANSWERED]

Asked by 8 years ago
Edited 8 years ago

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)

1 answer

Log in to vote
0
Answered by
Decemus 141
8 years ago
Edited 8 years ago

At Line 30, you can switch that to index a table of XP needed for each level. In order to do this, add a table at the beginning of the script that's something like,

local RequiredXP = {
[0] = 1000, -- [current level] = amount required to level up
[1] = 2257 -- You can easily add more for each level, but be aware that there will be a max level if you do it this way
}

You can index it by doing RequiredXP[levels.Value] and it will spit out whatever it equals.
( xpn.Value = RequiredXP[levels.Value] )

This allows for easy customization. As long as you know what you're doing, you'll be able to figure this out.

Or you can have it at a fixed rate where you just multiply it to get it at 2257. After that, you'll have to deal with some issues of where it might take too long to level up. If you're wondering what that rate is, it is 2.257.

0
@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? skillfulzombie88 28 — 8y
0
Did you make this script yourself? Decemus 141 — 8y
0
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 skillfulzombie88 28 — 8y
0
Do you understand how it works? Decemus 141 — 8y
View all comments (5 more)
0
Dammit, don't just hardcode the experience curve in. Write a function that will build it at runtime instead. Link150 1355 — 8y
0
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 skillfulzombie88 28 — 8y
0
i just posted the current script and i have no idea what the error is skillfulzombie88 28 — 8y
0
You switched the wrong line. I was referring to line 34. Decemus 141 — 8y
0
switched it and its still broken skillfulzombie88 28 — 8y
Ad

Answer this question