I have a very simple level up script and when a players EXP value hits a certain point its supposed to add a point to the level script but it doesnt? Nor does it error.
Does anyone know why?
Heres the script, its very simple just if a int value reaches a certain point then it level you up, very veryyy simple
local ReplicatedStorage = game:GetService("ReplicatedStorage") game.Players.PlayerAdded:connect(function(Player) local ExperiencePoints = ReplicatedStorage.DataFile:WaitForChild(Player.Name).ExperiencePoints local PlayerLevel = ReplicatedStorage.DataFile:WaitForChild(Player.Name).PlayerLevel while true do if ExperiencePoints.Value == "2500" then print("Level Up") PlayerLevel.Value = PlayerLevel.Value + 1 end wait() end end)
Its a script inside ServerScriptService incase you are wondering, anyhow have a good day and Merry Christmas!
this error is simple, you put the numbers in quotation marks, this makes the script check for a string value when it will never find one, that's why there is no error.
I have a similar script, but it's included with my Leaderstats portion of my DataStore, I'd recommend doing the same. :) Here's how I do it in my script, maybe this will help you.
local required = (PlayerLevel.Value*100) -- change the 100 to whatever factor you want each level to increase by, for example level 1 = 100 XP, level 2 = 200 XP, level 3 = 300 XP etc. ExperiencePoints.Changed:Connect(function() if ExperiencePoints.Value >= required then PlayerLevel.Value=PlayerLevel.Value+1 ExperiencePoints.Value = ExperiencePoints.Value-required end end)