I have a simple function that adds 1 exp point to a player every 2 seconds. It’s just a regular script located in the ServerScriptService. The function is not firing, but there are no error messages.
I tried locating the line of code in a separate script and even placed it in the StarterPlayerScripts. This is my first time creating a level system so I don’t entirely understand what’s going wrong here, it’s probably something obvious.
game.Players.PlayerAdded:Connect(function(player)
local level = Instance.new("IntValue", player)
level.Name = "Level"
level.Value = 1
local exp = Instance.new("IntValue", level)
exp.Name = "Current"
exp.Value = 0
local maxExp = Instance.new("IntValue", level)
maxExp.Name = "Max"
maxExp.Value = 100
exp.Changed:Connect(function(val)
if exp.Value >= maxExp.Value then
-- Do stuff.
level.Value = level.Value + 1
exp.Value = 0
maxExp.Value = maxExp.Value * 1.25
function additionXP()
player.Level.Current.Value = player.Level.Current.Value + 1
wait(2)
end
while true do
additionXP()
end
end
end)
end)