How to create a tool for tilling soil

i’m trying to create a script for a tool that will till soil (Like in Islands or similar games), however i’ve had no luck in getting anything to work. My attempt at writing it is here:

local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

tool.Activated:Connect(function()
	local target = mouse.Target
	if target and target:IsA("BasePart") then
		if target.Name == "GrassBlock" then
			target.Transparency = 1
		end
	end
end)

Is there a way to make a block change its transparency (or be modified in any way) when clicked on with a tool? Please let me know

question, is this script a localscript? the .LocalPlayer only works on the client.

its a localscript because it’s supposed to be for a tool

does the tool fire when activated?

i dont think it does but i tried using a remote event as well

add a print to see if it fires, if it does check if you’re geting a target or not

i managed to get it to work, all i did was change GrassBlock (Model name) to Grass (Part name). and also i had the tool disabled for some reason

nice, mistakes happens all the time

that or i genuinely have brain damage or something

i’ve spent 3 hours on a tool that wasn’t working until i found out i forgot to wrap the while loop in task.spawn().
the server script wasn’t receiving a OnServerEvent() because the while loop was preventing from listening the remote.

OR you’re doing just what you should be doing to learn how to master programming. You’re not going to make these mistakes again because you had to struggle for them. You don’t forget those lessons.