Level System Worked Perfectly Fine and Stopped Working All of a Sudden

The string value inside the Instance.new() function is incorrect, you have it as “IntValue” change it to “Folder”

1 Like

I copied you exact script and pasted it after Player.leaderstats.Exp and changed “name” to “Value” and it didn’t work. Did I do something wrong?

Player.leaderstats.Exp.Changed:Connect(function(Value)
local RequiredExp = Player.leaderstats.Level.Value * 100 + 100

	if Player.leaderstats.Exp.Value == RequiredExp or Player.leaderstats.Exp.Value >= RequiredExp then
		Player.leaderstats.Exp.Value -= RequiredExp
		Player.leaderstats.Level.Value += 1
	end
end)
1 Like

Wait i just realized it was the devforum doing it automatically “”

1 Like

The example script is a generic example which had typos originally, just keep name and wrap all the code in the .changed with an if name = value.

1 Like

I did this, I don’t really know what you mean. If you wrote that one part of the script for me that would probably fix it.

Player.leaderstats.Exp.Changed:Connect(function(name)
local RequiredExp = Player.leaderstats.Level.Value * 100 + 100

	if Player.leaderstats.Exp.Value == RequiredExp or Player.leaderstats.Exp.Value >= RequiredExp then
		Player.leaderstats.Exp.Value -= RequiredExp
		Player.leaderstats.Level.Value += 1
	end
end)

I’m not really an advanced scripter.

1 Like
Player.leaderstats.Exp.Changed:Connect(function(name)
	if name == "Value" then
		local RequiredExp = Player.leaderstats.Level.Value * 100 + 100

		if Player.leaderstats.Exp.Value >= RequiredExp then
			Player.leaderstats.Exp.Value -= RequiredExp
			Player.leaderstats.Level.Value += 1
		end
	end
end)
1 Like

Doesn’t work. :skull::gun: I don’t know what to do honestly and i’m probably gonna go to bed so I’ll just figure it out tomorrow but thanks for the help. I’ll be online for like 10 more mins.

1 Like

Geez yeah I guess that makes sense. Goodnight and idk why it’s broken

1 Like

Goodnight, I guess we can figure it out tomorrow.

1 Like

This might sound dumb, but check if the script is disabled

2 Likes

also where is the script???

1 Like

It’s enabled for sure. I would be dumb enough to not check though :skull:

1 Like

its located in server script service

1 Like

im gonna go to bed gnight yall

1 Like

Does the Exp in the leaderboard change at all?

1 Like

I updated a few things in your script. I changed Exp.Value.Changed to Exp.Changed, added some variables, and used them correctly (so instead of player.leaderstats.Exp.Changed, I just did Exp.Changed).

Code:

--//Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--//Variables
local LeaderstatsEvents = ReplicatedStorage.LeaderstatsEvents
local LevelUp = LeaderstatsEvents.LevelUp
local RankUp = LeaderstatsEvents.RankUp

--//Tables
local CodesInfo = {
	Code1 = "Coins25",
	Code2 = "Coins50",
	Code3 = "Gems5",
}

--//Functions
Players.PlayerAdded:connect(function(Player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = Player

	local Level = Instance.new("IntValue") 
	Level.Name = "Level" 
	Level.Parent = leaderstats

	local Exp = Instance.new("IntValue")
	Exp.Name = "Exp" 
	Exp.Parent = leaderstats

	local Coins = Instance.new("IntValue")
	Coins.Name = "Coins" 
	Coins.Parent = leaderstats

	local Gems = Instance.new("IntValue")
	Gems.Name = "Gems" 
	Gems.Parent = leaderstats

	--Other--
	local Rank = Instance.new("StringValue")
	Rank.Name = "Rank"
	Rank.Parent = Player

	--Quests--
	local QuestStats = Instance.new("Folder")
	QuestStats.Name = "QuestStats"
	QuestStats.Parent = Player

	local QuestNum = Instance.new("IntValue")
	QuestNum.Name = "QuestNum"
	QuestNum.Value = 1
	QuestNum.Parent = Player

	local QuestInProgress = Instance.new("BoolValue")
	QuestInProgress.Name = "QuestInProgress"
	QuestInProgress.Parent = Player

	--Quest Stats--
	local TimePlayed = Instance.new("IntValue")
	TimePlayed.Name = "TimePlayed"
	TimePlayed.Value = 0
	TimePlayed.Parent = QuestStats

	--Codes--
	local Codes = Instance.new("Folder")
	Codes.Name = "Codes"
	Codes.Parent = Player
	
	for codeName, codeReward in CodesInfo do
		local newCode = Instance.new("BoolValue")
		newCode.Name = codeName
		newCode.Parent = Codes
		
		local newReward = Instance.new("BoolValue")
		newReward.Name = "Reward"
		newReward.Value = codeReward
		newReward.Parent = newCode
	end

	--Stats--
	local PlayerStats = Instance.new("Folder")
	PlayerStats.Name = "PlayerStats"
	PlayerStats.Parent = Player

	--Boosts--
	local Boosts = Instance.new("Folder")
	Boosts.Name = "Boosts"
	Boosts.Parent = Player

	local CoinsBoost = Instance.new("IntValue")
	CoinsBoost.Name = "CoinsBoost"
	CoinsBoost.Value = 0
	CoinsBoost.Parent = Boosts

	local GemBoosts = Instance.new("IntValue")
	GemBoosts.Name = "GemsBoost"
	GemBoosts.Value = 0
	GemBoosts.Parent = Boosts

	--Update Log and Tutorial--
	local Updates = Instance.new("Folder")
	Updates.Name = "Updates"
	Updates.Parent = Player

	local Tutorial = Instance.new("BoolValue")
	Tutorial.Name = "Tutorial"
	Tutorial.Value = true
	Tutorial.Parent = Updates

	local BETA = Instance.new("BoolValue")
	BETA.Name = "BETA"
	BETA.Parent = Updates

	--Client Events--	
	Level.Changed:Connect(function()
		LevelUp:FireClient(Player)
	end)

	Rank.Changed:Connect(function()
		RankUp:FireClient(Player)
	end)  

	--Level System--
	Exp.Changed:Connect(function(newExp)
		local RequiredExp = Level.Value * 100 + 100

		if newExp >= RequiredExp then
			Exp.Value -= RequiredExp
			Level.Value += 1
		end
	end)
end)
1 Like

I’m just going to point something out, Value objects (IntValue, NumberValue, StringValue, etc…) only fire .Changed when their Value is changed anyways, so don’t worry about GetPropertyChangedSignal (it’s redundant.)

Also try wrapping arithmetic to ensure proper execution of arithmetic (somewhat redundant but may help)
local RequiredExp = (Player.leaderstats.Level.Value * 100) + 100

Also, your first check is redundant. You are using greater than OR equal (>=) to in your second check in the if statement, so you don’t need the equal to (==) check.

1 Like

Didn’t fix it. :expressionless: I don’t know what to do.

1 Like

No errors?

1 Like

Nope. No errors at all. Nothing seems to be working.

1 Like