Creating a time-based level system

Hey! I’m working on a game and I would like to implement a levels system. I want it to be 1 level every minute you are in the game. Does anyone have the script to this? Also I would like for it to show above their head and on the player list. I also want to have a statue of the highest person across all servers not just the one they are in. Sorry its a lot but I’m pretty new to scripting and don’t know how to do any of this. If you know any of this stuff please let me know.

1 Like

You could create a loop whenever a player joins the game, create a Level value, and every 60 seconds you could increase that value by 1.

1 Like

You have to create a new leaderstat called “Level.” Then change its level every 60 seconds which would look like:

		wait(60)
		Level.Value = Level.Value +1

Then in the same script create a datastore using data or data2 to save the levels.

For the name tags with levels, create the layout with a billboardgui and text labels, put it in ServerStorage then you can reference it in a script.

where would i put the level script at?

You would put the level script (or leaderstat script) in serverscriptservice.

1 Like

Sorry for being so complicated but there is red lines under “level” and I don’t know what to do.

Send me a picture of what you have so far. (or contact me for additional help at a person#8122)

I literally just have the script you gave me in serverscriptstorage named leaderstat. I have no clue what else to do.

If you just have:

		wait(60)
		Level.Value = Level.Value +1

It’s not going to work, you have to make a function and create the leaderstat first.

I figured, but how do I do that?

Create a function for Player.PlayerAdded. Make the leaderstat by using Instance.new(“IntValue”) and then define the properties. I am sure you can find some of this in an API and piece it together.

I’m sorry for being such a complicated person but I’m really new to scripting. I don’t know how to do ANY of that. :confused:

1 Like

Please spend some time doing research on the Developer Hub then. This category isn’t for getting spoonfed code but for pointing you in the right direction. You can search up the functions being referenced in posts at the aforementioned Developer Hub as well as use existing resources/threads that may be covering the same topic.

4 Likes

Ahhhh! Thanks for letting me know!

Hey! I’ve got it all I just can’t seem to figure out where to put the “wait(60)”.

Let’s start from zero then.(Note that I’m not going to use leaderstats but a raw level System.)
I’ll suppose that you’re making a rpg-like thing but with a diifferent idea.
This script also saves your data when you leave the game.

Insert a Script in ServerScriptService :


local DataStoreService = game:GetService("DataStoreService")

local StatDataStore = DataStoreService:GetDataStore("StatsData")


game.Players.PlayerAdded:Connect(function(plr)

local StatsFolder = Instance.new("Folder")
StatsFolder.Name = "StatsFolder"
StatsFolder.Parent = plr

local Level = Instance.New("IntValue")
Level.Name = ("Level")

local key = "p-"..plr.UserId

local sucess, errorm = pcall(function()

if sucess then

local LoadedData = StatDataStore:GetASync(key)

Level.Value = LoadedData[1]


else

end

end)


end)



game.Players.PlayerRemoving:Connect(function(plr)

local StatsFolder = plr:WaitForChild("StatsFolder")

local Level = StatsFolder:WaitForChild("Level")

local key = "p-"..plr.UserId

local StatsSaving = {Level}


local sucess, errorm = pcall(function()

if sucess then

StatDataStore:SetASync(key,StatsSaving)

else

end

end)



end)


game.Players.PlayerAdded:Connect(function(plr)


local StatsFolder = plr:WaitForChild("StatsFolder")

local Level = StatsFolder:WaitForChild("Level")

while true do 
wait(60) -- 60 seconds = 1 minute so...

Level.Value = Level.Value + 1 -- How much levels earn every minute.

end

end)

You need a UI to display It

Omg wow! Thank you! In this script will another level be added every minute? If not, do you know how to do that?

Well…
In this script, a level will be added every 60 seconds which means 1 minute.

Sorry! I see that now when I looked over it the first time my eyes skipped it.