Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script not detecting NumberValue changing?

Asked by
Plieax 66
5 years ago
Edited 5 years ago

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)

0
do not use .Value in variables. and change the value with server. yHasteeD 1819 — 5y

1 answer

Log in to vote
1
Answered by
yHasteeD 1819 Moderation Voter
5 years ago

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!

0
no error, just doesn't fire? Plieax 66 — 5y
0
You changed with server? yHasteeD 1819 — 5y
0
Yes Plieax 66 — 5y
0
Could it be where the script is located or the fact that it is a number value? Plieax 66 — 5y
View all comments (6 more)
0
For me this works. printed the "test" you are using a LocalScript or Server Script? yHasteeD 1819 — 5y
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 Plieax 66 — 5y
0
Its all working, and you set the value of AMOUNTLEFT to 5 correct? yHasteeD 1819 — 5y
0
yes Plieax 66 — 5y
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 Plieax 66 — 5y
0
Oh. I thought you were using remote events lol yHasteeD 1819 — 5y
Ad

Answer this question