Function not working

So im trying to fire this function and its not working, whenever the exp is higher than needed it does nothing in this function. It is suppose to put their exp vale to 0 after it is higher than needed.

	local function updateEXP(exp)
		print(expValue.Value)
		print(expToLevel.Value)
		if exp >= expToLevelUp(LevelStore:Get(defaultLevel)) then
			ExpStore:Increment(expToLevelUp(LevelStore:Get(defaultLevel)) * -1)
			LevelStore:Increment(1)
			game.Workspace["Level Up"]:Play()
			player.leaderstats.Exp.Value = 0
			game.StarterGui.Level.LevelUP.Visible = true
			wait(1) 
			game.StarterGui.Level.LevelUP.Visible = false
		else
			player.leaderstats.Exp.Value = exp
		end
		
		local expAtNextLevel = expToLevelUp(LevelStore:Get(defaultLevel))

		local currentlyHave = ExpStore:Get(defaultexp)

		player.leaderstats.ExpToLevel.Value = expAtNextLevel - currentlyHave
	
	end

replicatedStorage.Events.UpdateExp.OnServerEvent:Connect(function(plr, exp)
		print("Called")
		updateEXP(exp)
1 Like

Don’t need function do :Connect(plr, exp)

2 Likes

So then would it be like this?

	replicatedStorage.Events.UpdateExp.OnServerEvent:Connect(plr, exp)
		print("Called")
		updateEXP(exp)
		print("Called Agaun")

	local inventoryData = InventoryStore:Get({})
	inventoryString.Value = HttpService:JSONEncode(inventoryData)

	InventoryStore:OnUpdate(function(decodedData, player)
			if not decodedData then
			decodedData = ""
end
		inventoryString.Value =  tostring(decodedData)
		newTemplate.ArmorName.Value =  tostring(decodedData)
		print(decodedData.ClassName)
	end)
1 Like

Yes that would be correct. Hope this helps.

1 Like

Now it becomes unknown

1 Like

Then I don’t know sorry. Sorry

That’s wrong, and it will error if he does it like that, It should be :Connect(function(plr,exp)

@NotZylon Is there any errors in the output? Are you sure the event actually fires?

1 Like

yes, the prints i added print but it does nothing, no errors either

Why do need that just run the function (sorry I dont know you are what trying to do)

1 Like

I just noticed you’re changing the StarterGui instead of changing the PlayerGui, the player actually sees what’s inside the PlayerGui so you should be changing that instead. (StarterGui gets replicated to the PlayerGui but you shouldn’t be changing the StarterGui)

player.PlayerGui.Level.LevelUP
2 Likes

Try :Connect(updateEXP) or something

I think I know the else statement may be false
player.leaderstats.Exp.Value = exp
What is the value of exp?

im pretty surre it just nil but im not too sure since its only used in the function

2 Likes