How would I make a level and weapon xp system?

Hi devs, I want to make this XP system that unlocks weapons and items when u reach that level but I don’t know how to do it, I’ve tried simple scripts that I’ve found on the devs forums and it doesn’t work any ideas on how I would accomplish this task?
Here is the posts I’ve taken a look at in the forums:

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	local levelStat = Instance.new("IntValue")
	levelStat.Name = "Level"
	levelStat.Value = 0
	levelStat.Parent = leaderstats
	local xpStat = Instance.new("IntValue")
	xpStat.Name = "XP"
	xpStat.Value = 0
	xpStat.Parent = leaderstats
end)

This should help start you off. You’ll need to add ways to gain XP, convert XP to a level when a certain XP threshold is met and more.

What have you tried so far? Here because you linked my post, but I’m unsure how you applied it.

the problem is that I don’t know how to apply the script to my game I put the script in server script service and it doesn’t work.

My example wasn’t a script, it was a math problem.

To understand leveling, I recommend learning how to store any values in lua.

then what about this script?

--Weapon Info ModuleScript, where the rank requirements are stored and other things

local Info = {
	NormalMesh = "rbxassetid://95387789",
	
	GoldenMesh = "rbxassetid://126534866",
	
	LevelEXP = {
		[2] = 500,
		[3] = 1250,
		[4] = 2000,
		[5] = 3000,
		[6] = 4000,
		[7] = 6500,
		[8] = 8000,
		[9] = 10000,
		[10] = 12500,
		[11] = 15000,
		[12] = 18000,
		[13] = 21250,
		[14] = 25000,
		[15] = 30000,
		[16] = 32847234,
		}
	}

return Info```

EDIT: I will try and read an article about storing values and sorry for wasting your time I'm new to scripting

This script does nothing on its own, I would learn scripting first before diving into this.

1 Like