How can I make only one connection instead of multiple connections to the function?
--Variables
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local goodfarm = game.ServerStorage.GoodFarm
local badfarm = game.ServerStorage.BadFarm
local Farm = game.ServerStorage.Farm
local FarmClone
local Debounce = false
local found = game.ServerStorage:FindFirstChild("GoodFarm")
local found2 = game.ServerStorage:FindFirstChild("BadFarm")
local ClonedFarm = nil
--Move Part to Mouse Position Always
while true do
print(mouse.Target)
--Good
if mouse.Target == game.Workspace.Island then
mouse.TargetFilter = goodfarm
badfarm.Parent = game.ServerStorage
if found then
goodfarm.Parent = workspace
end
goodfarm.Position = mouse.Hit.p
--Problem |
-- \/
mouse.Button1Down:connect(function()
FarmClone = Farm:Clone()
FarmClone.Parent = workspace
end)
end
--Bad
if mouse.Target == game.Workspace.Water then
goodfarm.Parent = game.ServerStorage
mouse.TargetFilter = badfarm
if found2 then
badfarm.Parent = workspace
end
badfarm.Position = mouse.Hit.p
end
if Debounce == true then
goodfarm.Parent = game.ServerStorage
badfarm.Parent = game.ServerStorage
break
end
wait()
end

2 comments
remove the while loop and put your if statements in the function.
Heres a video why that wont work. https://www.youtube.com/watch?v=wnyjtkUSP1k