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

IntValue doesn't increase using LocalScript, how do i fix this?

When i try to increase IntValue, nothing happens, this is mostly the script i use

value = script.Parent.Value

value = value + 1

but it isn't working when i try doing it for menu

1 comment

0

Ok give us more info, what is "value", where did you put "value" where did you put the LocalScript?, any error in the output window? what do you mean trying to do it for menu?

2 answers

✓ Accepted answer

If we look at the code from the script's perspective we'll be able to find out what's actually going on.

-- The variable will get a number value
-- because of "script.Parent.Value"

-- let's imagine the returned number value is 3
value = script.Parent.Value


value = value + 1
-- The code above will pretty much translate to the following:
3 = 3 + 1

Let's now move on the solution

-- Instead of getting the number value, we instead
-- get the object itself.
object = script.Parent

-- and then set the property "Value" to the previous value
-- with a increment of 1
object.Value = object.Value + 1

3 comments

0

i will try this

0

no doesn't work still

0

The change is not read by the client? If it still isn't, it probably means that the script cannot find the IntValue. Use WaitForChild().

value = script.Parent.Value.Value

value = value + 1

You forgot to get into the value property

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