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

Why doesnt this multiplication script update?

Hi, I have a script that's speed is determined by a numbervalue. The numbervalue updates frequently, but these updates aren't recognized.

local blinkspeed = script.BlinkSpeed.Value

while true do
	if (blinklev > 0) then
			wait(0.03)
			script.Parent.smokeframe.Visible = false
			blinklev = blinklev - (0.033 * blinkspeed)
			meter.Size = meter.Size - UDim2.new(0, (1 * blinkspeed), 0, 0)

Please note this is just a snippet of code, the "end"s are located later.

2 comments

0

try removing the ".Value" at line one and add it everywhere you typed "blinkspeed" ex: "blinkspeed.Value"

0

heya you fixed it. thank you!

1 answer

That's because when you do

local blinkspeed = script.BlinkSpeed.Value

blinkspeed is not equal to the object, but the number. For example, if script.BlinkSpeed.Value = 10, then blinkspeed = 10.

Thus, if script.BlinkSpeed.Value changes, then the script won't recognize it, since blinkspeed is only a number, not an object.

Instead, you should use the .Changed event to be triggered whenever the value of script.BlinkSpeed.Value changes.

local blinkspeed = script.Blinkspeed --note that I changed 'blinkspeed' to the object, not the property

blinkspeed.Changed:connect(function()
	--code
end)

You may need to change this to fit your script.

1 comment

0

Doesn't seem to fit what I'm asking; the script doesn't fire when the value changes, but is altered. Additionally it's a number value because it's being multiplied, I'm pretty sure you can't multiply objects.

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