width = script.Parent.Size.X P = script.Parent.Parent.Parent.Parent Front = script.Parent P.leaderstats.EXP.Changed:connect(function() if P.leaderstats.EXP > (P.leaderstats.MaxEXP) then P.leaderstats.Level.Value = P.leaderstats.LastLevel.Value + 1 P.leaderstats.EXP.Value = 0 P.leaderstats.MaxEXP.Value = P.leaderstats.Level.Value * 59 end local width = P.leaderstats.EXP / P.leaderstats.Level / 59 Front.Size = UDim2.new(0, width, 0, Front.Size.Y.Offset) end)
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.
local width = script.Parent.Size.X local P = script.Parent.Parent.Parent.Parent local Front = script.Parent P.leaderstats.EXP.Changed:connect(function() if P.leaderstats.EXP > (P.leaderstats.MaxEXP) then P.leaderstats.Level.Value = P.leaderstats.LastLevel.Value + 1 P.leaderstats.EXP.Value = 0 P.leaderstats.MaxEXP.Value = P.leaderstats.Level.Value * 59 end local width = P.leaderstats.EXP.Value / P.leaderstats.Level.Value / 59 Front.Size = UDim2.new(0, width, 0, Front.Size.Y.Offset) end)
Additionally, you can just turn the TextScaled property to true.