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

Script not detecting NumberValue changing?

The part that fires it is at the bottom. No errors. The print("test") part doesnt fire when the amount is changed.

local al = script.Parent.AMOUNTLEFT

function changed()
	print("test")
	local nl = script.Parent.AMOUNTLEFT.Value
	for i,v in pairs(script.Parent:GetChildren())do
		if v.Name == "Bamboo 1" then
			for i,vv in pairs(v:WaitForChild("Bamboo 1")["Parts to (Collect)"]:GetChildren())do
				if nl == 5 then
					if vv.Name == "B1" then
						vv.Transparency = 0
					end 
										if vv.Name == "B2" then
						vv.Transparency = 0
										end 
															if vv.Name == "B3" then
						vv.Transparency = 0
															end 
																				if vv.Name == "B4" then
						vv.Transparency = 0
																				end 
																									if vv.Name == "B5" then
						vv.Transparency = 0
					end 
				end
								if nl == 4 then
					if vv.Name == "B1" then
						vv.Transparency = 1
					end 
										if vv.Name == "B2" then
						vv.Transparency = 0
										end 
															if vv.Name == "B3" then
						vv.Transparency = 0
															end 
																				if vv.Name == "B4" then
						vv.Transparency = 0
																				end 
																									if vv.Name == "B5" then
						vv.Transparency = 0
					end 
								end
												if nl == 3 then
					if vv.Name == "B1" then
						vv.Transparency = 1
					end 
										if vv.Name == "B2" then
						vv.Transparency = 1
										end 
															if vv.Name == "B3" then
						vv.Transparency = 0
															end 
																				if vv.Name == "B4" then
						vv.Transparency = 0
																				end 
																									if vv.Name == "B5" then
						vv.Transparency = 0
					end 
												end
																if nl == 2 then
					if vv.Name == "B1" then
						vv.Transparency = 1
					end 
										if vv.Name == "B2" then
						vv.Transparency = 1
										end 
															if vv.Name == "B3" then
						vv.Transparency = 1
															end 
																				if vv.Name == "B4" then
						vv.Transparency = 0
																				end 
																									if vv.Name == "B5" then
						vv.Transparency = 0
					end 
																end
																				if nl == 1 then
					if vv.Name == "B1" then
						vv.Transparency = 1
					end 
										if vv.Name == "B2" then
						vv.Transparency = 1
										end 
															if vv.Name == "B3" then
						vv.Transparency = 1
															end 
																				if vv.Name == "B4" then
						vv.Transparency = 1
																				end 
																									if vv.Name == "B5" then
						vv.Transparency = 0
					end 
																				end
																				
																																								if nl == 0 then
					if vv.Name == "B1" then
						vv.Transparency = 1
					end 
										if vv.Name == "B2" then
						vv.Transparency = 1
										end 
															if vv.Name == "B3" then
						vv.Transparency = 1
															end 
																				if vv.Name == "B4" then
						vv.Transparency = 1
																				end 
																									if vv.Name == "B5" then
						vv.Transparency = 1
					end 
				end
			end
		end
	end
end



script.Parent.AMOUNTLEFT.Changed:Connect(changed)

1 comment

0

do not use .Value in variables. and change the value with server.

1 answer

✓ Accepted answer

Do not use .Value in variables.

you can try this:

local al = script.Parent.AMOUNTLEFT

function changed()
    print("test")
    local nl = script.Parent.AMOUNTLEFT
    for i,v in pairs(script.Parent:GetChildren())do
        if v.Name == "Bamboo 1" then
            for i,vv in pairs(v:WaitForChild("Bamboo 1")["Parts to (Collect)"]:GetChildren())do
                if nl.Value == 5 then
                    if vv.Name == "B1" then
                        vv.Transparency = 0
                    end 
                                        if vv.Name == "B2" then
                        vv.Transparency = 0
                                        end 
                                                            if vv.Name == "B3" then
                        vv.Transparency = 0
                                                            end 
                                                                                if vv.Name == "B4" then
                        vv.Transparency = 0
                                                                                end 
                                                                                                    if vv.Name == "B5" then
                        vv.Transparency = 0
                    end 
                end
                                if nl.Value == 4 then
                    if vv.Name == "B1" then
                        vv.Transparency = 1
                    end 
                                        if vv.Name == "B2" then
                        vv.Transparency = 0
                                        end 
                                                            if vv.Name == "B3" then
                        vv.Transparency = 0
                                                            end 
                                                                                if vv.Name == "B4" then
                        vv.Transparency = 0
                                                                                end 
                                                                                                    if vv.Name == "B5" then
                        vv.Transparency = 0
                    end 
                                end
                                                if nl.Value == 3 then
                    if vv.Name == "B1" then
                        vv.Transparency = 1
                    end 
                                        if vv.Name == "B2" then
                        vv.Transparency = 1
                                        end 
                                                            if vv.Name == "B3" then
                        vv.Transparency = 0
                                                            end 
                                                                                if vv.Name == "B4" then
                        vv.Transparency = 0
                                                                                end 
                                                                                                    if vv.Name == "B5" then
                        vv.Transparency = 0
                    end 
                                                end
                                                                if nl.Value == 2 then
                    if vv.Name == "B1" then
                        vv.Transparency = 1
                    end 
                                        if vv.Name == "B2" then
                        vv.Transparency = 1
                                        end 
                                                            if vv.Name == "B3" then
                        vv.Transparency = 1
                                                            end 
                                                                                if vv.Name == "B4" then
                        vv.Transparency = 0
                                                                                end 
                                                                                                    if vv.Name == "B5" then
                        vv.Transparency = 0
                    end 
                                                                end
                                                                                if nl.Value == 1 then
                    if vv.Name == "B1" then
                        vv.Transparency = 1
                    end 
                                        if vv.Name == "B2" then
                        vv.Transparency = 1
                                        end 
                                                            if vv.Name == "B3" then
                        vv.Transparency = 1
                                                            end 
                                                                                if vv.Name == "B4" then
                        vv.Transparency = 1
                                                                                end 
                                                                                                    if vv.Name == "B5" then
                        vv.Transparency = 0
                    end 
                                                                                end

                                                                                                                                                                if nl.Value == 0 then
                    if vv.Name == "B1" then
                        vv.Transparency = 1
                    end 
                                        if vv.Name == "B2" then
                        vv.Transparency = 1
                                        end 
                                                            if vv.Name == "B3" then
                        vv.Transparency = 1
                                                            end 
                                                                                if vv.Name == "B4" then
                        vv.Transparency = 1
                                                                                end 
                                                                                                    if vv.Name == "B5" then
                        vv.Transparency = 1
                    end 
                end
            end
        end
    end
end



script.Parent.AMOUNTLEFT.Changed:Connect(changed)

Hope it helped :D

Errors? tell-me on comments!

10 comments

0

no error, just doesn't fire?

0

You changed with server?

0

Yes

0

Could it be where the script is located or the fact that it is a number value?

0

For me this works. printed the "test" you are using a LocalScript or Server Script?

0

im using a server script, it is inside of a group which has that number value in it, when i change it nothing happens, ive tried a simple .Changed:Connect(function() in a different script. Still nothing

0

Its all working, and you set the value of AMOUNTLEFT to 5 correct?

0

yes

0

i figured it out. I was using the command bar at the bottom of studio thinking it would work but it doesnt. Sorry for the waste of time

0

Oh. I thought you were using remote events lol

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