Changed isn't firing in my script, for some reason

I want the gui to change when the numbervalue is changed. But it’s not firing “Changed”. Neither prints (i have those for bug testing) fire. I have seen if it is a problem with the changing script, but it definitely isn’t because I have manually changed AmountOfSandInBucket myself on the Server side, so it is a problem with Changed.

script.Parent.Parent.AmountOfSandInBucket.Changed:Connect(function()
	print("yes so")
	local amountofsand = script.Parent.Parent.AmountOfSandInBucket
	if amountofsand.Value >= script.Parent.Parent.MaxSandInBucket.Value then
		print("ok thats good")
		amountofsand.Value = script.Parent.Parent.MaxSandInBucket.Value
	end
	script.Parent.Parent.Bucket.SurfaceGui.TextLabel.Text = amountofsand.Value
end)

Note: Sometimes is fires… sometimes.

I recommend you to use local variables instead of using script.parent.parent sometimes it doesn’t find the variable you want, so use “local” to give your variable a name and I recommend again to use “Wait for child:()”

Firstly, organise the code, use local variables, and use WaitForChild().

The problem isn’t anything inside the code itself. It just doesn’t fire.

Try using :GetPropertyChangedSignal(“Value”). .changed() has a history for not firing all the time on num values

3 Likes

wait but like what if i use int values do those count as them?

Same thing would happen, just use the method I provided

Perhaps I’m way off but it looks like you’re waiting for the changed event to happen and then setting the values inside it causing the changed event to happen. Could cause issues I think.