local n=script.Parent local F=game.Players.LocalPlayer local C=F:GetMouse()local a=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local E=n:WaitForChild("\072\097\110\100\108\101")local l=E:WaitForChild("\065\108\108\111\119\080\108\097\099\101\109\101\110\116")local O;(n:WaitForChild("\082\101\109\111\116\101\070\117\110\099\116\105\111\110")).OnClientInvoke=function(...)return C.Target,C.Hit.p end local i n.Equipped:Connect(function()i=a.InputBegan:Connect(function(F,a)if a then return end if not l.Value then return end if F.UserInputType==Enum.UserInputType.Keyboard then if F.KeyCode==Enum.KeyCode.E then(n:WaitForChild("\082\101\109\111\116\101\069\118\101\110\116")):FireServer(C.Target,C.Hit.p)end end end)end)n.Unequipped:Connect(function()if not l.Value then return end i:Disconnect()i=nil end);(n:WaitForChild("\082\101\109\111\116\101\069\118\101\110\116")).OnClientEvent:Connect(function(n,F)O=n if F then O.TextLabel.Text="\083\111\105\108\058 "..F end end)


local Tool = script.Parent
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local UIS = game:GetService("UserInputService")
local Handle = Tool:WaitForChild("Handle")
local CanPlace = Handle:WaitForChild"AllowPlacement"
local GUI

Tool:WaitForChild("RemoteFunction").OnClientInvoke = function(...)
	return Mouse.Target,Mouse.Hit.p
end

local _C

Tool.Equipped:Connect(function()
	_C = UIS.InputBegan:Connect(function(Input,GPE)
		if GPE then return end
		if not CanPlace.Value then return end
		if Input.UserInputType == Enum.UserInputType.Keyboard then
			if Input.KeyCode == Enum.KeyCode.E then
				Tool:WaitForChild("RemoteEvent"):FireServer(Mouse.Target,Mouse.Hit.p)
			end
		end
	end)
end)

Tool.Unequipped:Connect(function()
	if not CanPlace.Value then return end
	_C:Disconnect()
	_C = nil
end)

Tool:WaitForChild("RemoteEvent").OnClientEvent:Connect(function(Gui,SoilCount)
	GUI = Gui
	if SoilCount then
		GUI.TextLabel.Text = "Soil: "..SoilCount
	end
end)
