Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

.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.

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)


1 comment

0

Posting random code with no explanation at all doesn't help anyone.

This discussion is preserved as it was. New answers, comments, and votes are closed.