Hello, I am a new programmer and sadly, I don't know much about scripting. I have been trying the script listed below to safe data for a XP-Clicker type game. I got this error message. " Maximum event re-entrancy depth exceeded for IntValue.Changed."
And here is the script with the trouble.
--[Author: QNCL0]--
game.Players.PlayerAdded:Connect(function(player) local level = Instance.new("IntValue", player) level.Name = "Level" level.Value = 1 local XP = Instance.new("IntValue", level) XP.Name = "Current" XP.Value = 0 local maxXP = Instance.new("IntValue", level) maxXP.Name = "Max" maxXP.Value = 100 XP.Changed:Connect(function(val) if XP.Value >= maxXP.Value then player.Level.Current.Value = player.Level.Current.Value + 1 XP.Value = 0 maxXP.Value = maxXP.Value * 1.33 -- Changes how much it multiplies when leveled up end end) end) workspace:WaitForChild("GiveXP").ClickDetector.MouseClick:Connect(function(player) player.Level.Current.Value = player.Level.Current.Value + 33 --Gives the player XP end)
In this script, I am trying to add a value to "Current" everytime it hits the maximum amount.