Value Amount needed! (IntValue)

Howdy DevForum! I am trying to make a script so that when this IntValue gets a certain amount it will delete these 2 text and will enable these 2 scripts inside a part. I get no errors in the output and dev console. Please help!

local Amount = script.Parent.Parent.AmountBoard.AmountDisplayPart.Amount.Value
	if Amount == 550 then
		script.Parent.Teleporter.CurrencyGiver.Disabled = false
		script.Parent.Teleporter.Teleport.Disabled = false
		script.Parent.LockedText:Destroy()
		script.Parent.Needed:Destroy()
	end
2 Likes

You need to use a listening event, for example;

amount.Changed:Connect(function()
if amount.Value == number then
-- do stuff
end
end)

Take value off of the end of your variable, this event only works with instances.

And there’s also,

amount:GetPropertyChangedSignal("Value"):Connect(function()
if amount.Value == number then
-- do stuff
end
end)

The first one fires when any value of the instance has changed, :GetPropertyChangedSignal() allows you to listen for the differences in specific properties.

2 Likes

Make sure to change it to >= instead of ==. If you want it at a certain amount then you would do the following.

2 Likes

Why is this? I thought the double equals operator worked fine.

He asked for a certain amount. The equal operator only works if two numbers are exactly the same. Using this operator, >= allows the script to check if its equal or above.

Oh, sorry. I didn’t read the certain amount part. I understand why you’d use it here now, thanks :smile:

There are other operators such as ~=, <= but the code shown in the picture was probably either a mistake or just intended.

1 Like

I’m aware of, I think all the operators at this point it’s just that I didn’t read the certain value part.

1 Like

This does not seem to be working, and .Changed does not work on this value I am pretty sure. And I did try what @KingAchieve said. This is also a regular script not a local script.

Is the value being changed on the client? if it is, it doesn’t work like that.

1 Like

Did you take value off the end of your variable?

Oh right, sorry! I am testing again.

2 Likes

Thank you so much! I learned more about value changing. Thank you!

1 Like