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

How can you make it so that the player can use the click detector to click things more than once?

Asked by 7 years ago
Edited 7 years ago

So I do not really know if you can let the player use a click detector to click things more than once. Here's what I am trying to do. I am trying to let a player click a section of the garden to plant a crop. When they hover over a section of their garden, they can click to popup a gui to pick which crop to plant and they must click which one to plant. Then, they have to click a section of the garden to plant the crop, but they can only do this once until they have to click the gui button again. Is there a way to let them click more sections of the garden to plant instead of having to click the gui each time. Here's kind of a sample of my code:

stored is the frame

corn is the button inside of stored

clickDetector.MouseClick:connect(function()
    stored.Visible = true
    corn.MouseButton1Down:connect(function()

        clickDetector.MouseClick:connect(function()

            for i, v in pairs(target:GetChildren()) do
                if v and v.Name == "Seed" and v.Parent.Number.Value == realNumber.Value and v.Transparency == 1 and storedValue and storedValue.Value >= 1 then
                    print("Seed Working")
                    v.Transparency = 0
                    storedValue.Value = storedValue.Value - 1
                    cornText.Text = "Corn: "..storedValue.Value
                end
            end

        end)                
    end)
end)

Any help is appreciated!

Answer this question