Issue with NumberValue

Nothing happens after NumberValue passes 60, and nothing happens before it passes 60.

systemissue1 = script.Parent.Parent.Parent.Parent.Helicopter.Body.Avanta.Body.systemissue1
smokeL = systemissue1.Parent.Leftengine.Smokes
smokeR = systemissue1.Parent.Rightengine.Smokes
hits = script.Parent
Value = hits.Value

Value.Changed:Connect(function()
	if Value > 60 then
		smokeR.Parent.Leftengine.Smokes.Enabled = true
		smokeL.Enabled = true
		systemissue1:Play()
	else
		warn("Value not 60 yet")
	end
end)

image

1 Like

The problem with your script is that you made a variable that included .Value, and used that variable for the changed event. You can’t use the Changed event on a Value Property. Remove that Value variable.

Here is your fixed script:

systemissue1 = script.Parent.Parent.Parent.Parent.Helicopter.Body.Avanta.Body.systemissue1
smokeL = systemissue1.Parent.Leftengine.Smokes
smokeR = systemissue1.Parent.Rightengine.Smokes
hits = script.Parent

hits.Changed:Connect(function()
	if hits.Value > 60 then
		smokeR.Parent.Leftengine.Smokes.Enabled = true
		smokeL.Enabled = true
		systemissue1:Play()
	else
		warn("Value not 60 yet")
	end
end)
1 Like

I don’t think you can used .Changed on the Value, instead you could do this:

hits.Changed:Connect(function()
	if hits.Value > 60 then
		smokeR.Parent.Leftengine.Smokes.Enabled = true
		smokeL.Enabled = true
		systemissue1:Play()
	else
		warn("Value not 60 yet")
	end
end)

That should work!

EDIT: I just realised someone already solved it, I was late.

actually both of these fixes don’t seem to be working for me
(script is supposed to enable two smoke particle emitters and play a sound after the rotorblades of the helicopter hits a part 60+ times)
heres a clip of the issue

adding onto this, i’ve asked a few people a few hours ago and haven’t yet got it fixed

I am a little confused. Are you receiving any errors in the output? If you are, could you please show us the error (screenshot or in text)?

Maybe you should try using a IntValue, instead of a NumberValue.

i am attempting to use the numbervalue’s value to detect when a particle emitter should be enabled (after the value is greater than 60, it should enable.) Also, i’ve not encountered any errors in console or anything in output.

1 Like

just tried it, also ran into the same problem

instead of using .Changed just use a while loop

Example:

systemissue1 = script.Parent.Parent.Parent.Parent.Helicopter.Body.Avanta.Body.systemissue1
smokeL = systemissue1.Parent.Leftengine.Smokes
smokeR = systemissue1.Parent.Rightengine.Smokes
hits = script.Parent
Value = hits.Value

while wait() do
	if Value > 60 then
		smokeR.Parent.Leftengine.Smokes.Enabled = true
		smokeL.Enabled = true
		systemissue1:Play()
	else
		warn("Value not 60 yet")
	end
end

I have had the same issues in the past, This Seems To Fix It

Is the Value being changed from the Server or the Client? Maybe that could be the issue. If you are changing the Value on the Client, the Server will not detect the changes.

That’s what I was thinking but however it can run in to some problems by not continuing the rest of the code. So once the value is past 60, you need to break it. Usually I would also run it in a coroutine.

Using a while loop is not good practice, and could cause unnecessary lag if you do not break the loop. There is also another option where you could use GetPropertyChangedSignal. This can be used to detect any changes of a property

this might be part of the problem, the value is changing server-side.

Have you tried printing messages? If not, add prints to some parts of the script and see which ones print and which ones doesn’t

But the script is also serversided so I’m kind of confused.

i attempted this earlier and had nothing print

Try using the GetPropertyChangedSignal event, let me know if that works or not.

systemissue1 = script.Parent.Parent.Parent.Parent.Helicopter.Body.Avanta.Body.systemissue1
smokeL = systemissue1.Parent.Leftengine.Smokes
smokeR = systemissue1.Parent.Rightengine.Smokes
hits = script.Parent

hits:GetPropertyChangedSignal("Value"):Connect(function()
	if hits.Value > 60 then
		smokeR.Parent.Leftengine.Smokes.Enabled = true
		smokeL.Enabled = true
		systemissue1:Play()
	else
		warn("Value not 60 yet")
	end
end)

doesn’t seem to be working either.

This is probably the last thing I could think of, maybe make those variables into local variables instead of global variables? I don’t think this would make any difference, but try and see:

local systemissue1 = script.Parent.Parent.Parent.Parent.Helicopter.Body.Avanta.Body.systemissue1
local smokeL = systemissue1.Parent.Leftengine.Smokes
local smokeR = systemissue1.Parent.Rightengine.Smokes
local hits = script.Parent

hits:GetPropertyChangedSignal("Value"):Connect(function()
	if hits.Value > 60 then
		smokeR.Parent.Leftengine.Smokes.Enabled = true
		smokeL.Enabled = true
		systemissue1:Play()
	else
		warn("Value not 60 yet")
	end
end)