You have million ways to create level systems. It’s really up to you though.
Assuming levels work with EXP points, you can either:
- Each level has a set EXP goal, when met player levels up and their EXP is set back to 0 (or more if on level up exp overflows)
- Level is determined by total EXP gained (ex. 1 needs 200, 2 requires 500, however exp is never reset to 0)
To do these, you need to plan out how your leveling logic works. This is an example you would not want to do:
local levels = {
100,
200,
300
}
-- now if we want to see the exp required for each level:
for level, required in ipairs(levels) do
print("Required EXP for level " .. level .. ": " .. required)
end
--[[ Output:
Required EXP for level 1: 100
Required EXP for level 2: 200
...
]]
Well, don’t do that. You have way easier ways to do that, one of them is creating a logic, so the exp required for each level increases from previous level.
Additionally we want that level and EXP gained to save between sessions, this requiring the use of DataStoreService.
To grant items, use a function. When the player levels up, i.e. hits a certain EXP amount, said function is fired. Within that function we check the current player level, if it meets a certain required level, we grant the player an item (which can be a tool or anything you require.)
Just make sure you don’t use elseif
statements when checking new player level:
function onPlayerLeveledUp(newLevel)
if newLevel == 10 then
-- item
elseif newLevel == 20 then
-- item
end
-- In short, just, don't.
end
We’re not YandereDev.
It’s all about trial and failure. I can’t provide with a full script, because, meh, no spoonfeeding here.