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

Help! Variable changing halfway through script without me knowing why?

Asked by 7 years ago
Edited 7 years ago

So have a script,

function Planting(Dirty)
    if Dirty:FindFirstChild("Clicks") then
        print("dirt1")
        else
        print("dirt2")
    end
    print("AND THIS DOESNT")
    ToGrow()
    ToDo.Adornee=Dirty.Dirt

    Do.MouseButton1Click:connect(function()
        if Dirty:FindFirstChild("Clicks") then
        print("dirt1")
        else
        print("dirt2")
        end
        if Do.BackgroundColor3==Color3.new(128,255,0) then
            print("clicked")
            Seeds.Visible=true
            ToDo.Adornee=nil
            Seeds.Dirt.Value=(Dirty)
                if Dirty:FindFirstChild("Clicks") then
                    print("dirt1")
                    else
                    print("dirt2")
                end
            print("yeah")
        end
    end)
end

So the first time it is http://prntscr.com/bs7spb Everything works fine, it prints what it should. Then I click again:

http://prntscr.com/bs7tfv

As you can see, it has added another "dirt1") But thats not all.

I had also tested it with button 2, and this time it printed 3 2s AND 4 dirts

http://prntscr.com/bs7u4c

I have no idea why it is doing this!!!!

ToGrow() is also just for cosmetic purposes:

    Do.BackgroundColor3=Color3.new(128,255,0)
    Do.TextColor3=Color3.new(0,128,64)
    Do.Text=("Grow")

If anyone could help me out, I would really appreciate that, thanks.

Answer this question