Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

My script to change Gui Front on EXP changed won't work?

Asked by 9 years ago
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)

0
Just Turn TextScaled on. Goulstem 8144 — 9y
1
Shouldn't there be a 'Value' after .EXP and .Level? Wizzy011 245 — 9y
0
^ Lines 11 and 12 Goulstem 8144 — 9y

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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.

Ad

Answer this question