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

IntValue script will not work! I keep getting this error "index field 'Value'" ! HELP?

Asked by 7 years ago
local Progress = script.Parent
local Player = game.Players.LocalPlayer

Player.EXP.Value.Changed:connect(function()
    Progress.Size = Progress.Size + Progress.UDim2.new(0,40,0,0)
end)

Player.Level.Value.Changed:connect(function()
    Progress.Size = Progress.UDim2.new(0,40,0,0)
    script.Parent.Text = Player.Level.Value
end)

Output 16:21:51.904 - Players.Player1.PlayerGui.Level Up Bar.Holding Bar.Frame.LocalScript:6: attempt to index field 'Value' (a number value)

2 answers

Log in to vote
0
Answered by 7 years ago

.Changed is on the IntValue itself, not on its Value property

valueObj.Changed:connect(function(val)
    print(val) --will print the new value
end)

Not that .Changed on values work differently than on other Instances. On values, it only triggers when Value changes and it'll be the new value. On all other instance types, its the property name that was changed.

Ad
Log in to vote
0
Answered by
Scrxptss -13
7 years ago
Edited 7 years ago
local Progress = script.Parent
local Player = game.Players.LocalPlayer

Player.EXP.Changed:connect(function()
    Progress.Size = Progress.Size + Progress.UDim2.new(0,40,0,0)
end)

Player.Level.Changed:connect(function()
    Progress.Size = Progress.UDim2.new(0,40,0,0)
    script.Parent.Text = Player.Level.Value
end)


0
Posting random code with no explanation at all doesn't help anyone. Kampfkarren 215 — 7y

Answer this question