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

How to change an object IntValue's value with a script?

Here is my code:

--Variables

local Drill = script.Parent
local DrillUpper = Drill:FindFirstChild("Drill upper")
local DrillTransparency = DrillUpper.Transparency
local Money = Drill.parent.parent:FindFirstChild("CurrencyToCollect")

--Variables

--Testing

print (DrillUpper.Name)
print (Drill.Name)
print (Money)
print (DrillTransparency)

--Testing

--Function

local function TransparencyTest()
	print ("function works")
	wait (2)
	if DrillTransparency == 0 then
		while (true) do
			Money.value = Money.value + 1 
			
			print (Money)
			wait(1)
		end
	end
end

--Function

--The program

TransparencyTest()

--The program

Why doesn't the object variable change?
It is no errors.
I saw im am not the only one having problems with this, but they deleted the code so I didn't understand it fully.

7 comments

2

Is the IntValue you are trying to change 'Money'? If so, a common mistake is to forget to access the Value property when updating IntValue values. Just use Money.Value instead. e.g. Money.Value = Money.Value + 1

0

@123marble that's the answer, put it as an answer so someone else doesn't

0

No I am not trying to change Money. I am trying to change CashToCollect object that is in the workspace. I have a variable in the upper section.

0

CashToCollect is assigned to the Money variable though?

0

yes

0

Use an if statement and a print() to see if Money is not nil.

0

I have tried and Money isn't nil. I just need help to change CashToCollect that is an int variable OBJECT. Money is just a variable I used in the script, if I need to delete it i will do it.

2 answers

✓ Accepted answer

All I can really see is on line 26, you have Money.value, capitalization really matters, so make sure to change anywhere it says .value, to .Value. The V in Value always has to be capital.

Also, make sure when you run the game, the DrillTransparency is set to 0.

1 comment

0

thank you very much

"Is the IntValue you are trying to change 'Money'? If so, a common mistake is to forget to access the Value property when updating IntValue values. Just use Money.Value instead. e.g. Money.Value = Money.Value + 1".

Yeah, that's the correct answer, so it might work like this, change the line 26 become this:

Money.Value = Money.Value + 1

If it worked, mark this as the correct answer, also thanks for 123marble too.

1 comment

0

It didn't work

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