How to make if there's IntValue = 5 it detects and changes something

Hey (i am really sorry that i was asking for help third time, but i am still learning LUA).

I had a problem which I don’t know how I can make that if there is IntValue for example “5” it changes something.

It means, if there will be Value “5” it changes something.

local NumberValue = Instance.new("NumberValue")
NumberValue.Parent = game.Workspace

NumberValue:GetPropertyChangedSignal("Value"):Connect(function(Value : number)
    if Value == 5 then
        ---Do something cool
   end
end)

Notice:
Since it is a number, you could’ve simply used .Changed instead.

1 Like

GetPropertyChangedSignal doesn’t pass any values to connected callback functions.

local NumberValue = Instance.new("NumberValue")
NumberValue.Parent = game.Workspace

NumberValue.Changed:Connect(function(Number)
	if Number == 5 then
		--Do code.
	end
end)

As recommended here, Changed should be used instead.

2 Likes

Ahh, yes, ofc, simple mistake. Remembering each method is hard when you have to know so many with so many languages. I appreciate you for pointing that out.

wait, what if i want to make in StarterGui this script? (local? or normal.):

script.Parent.sound.playing = true
wait(0)
script.Parent.script.Disabled = true
wait(0)
script.Parent.script2.Disabled = false

it will work? i tried to make like this, and i was still thinking…