Credit to Wizzy011 for pointing this out
Your problem is that you failed to index the Value
of the EXP and Level Values on line 11
and line 12
- so you're essentially attempting to use arithmetic on an Instance, which will return in an error.
01 | local width = script.Parent.Size.X |
02 | local P = script.Parent.Parent.Parent.Parent |
03 | local Front = script.Parent |
05 | P.leaderstats.EXP.Changed:connect( function () |
06 | if P.leaderstats.EXP > (P.leaderstats.MaxEXP) then |
07 | P.leaderstats.Level.Value = P.leaderstats.LastLevel.Value + 1 |
08 | P.leaderstats.EXP.Value = 0 |
09 | P.leaderstats.MaxEXP.Value = P.leaderstats.Level.Value * 59 |
11 | local width = P.leaderstats.EXP.Value / P.leaderstats.Level.Value / 59 |
12 | Front.Size = UDim 2. new( 0 , width, 0 , Front.Size.Y.Offset) |
Additionally, you can just turn the TextScaled property to true.