Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make it so if you click a block with a tool, it will make the block go invisible?

So, I am making a new game and I need it so if someone clicks a block, it will make the block go invisible, but I need it to only go invisible if they press the block with a certain tool. I am going to have many blocks in the world, so I want it to only effect the one I press. Someone told me to try a roblox scripting wiki, but I don't understand it. Please help.

1 comment

0

i don't know but good luck on that

1 answer

✓ Accepted answer

Use the Activated event of the Tool object which fires every time the player clicks with that tool. Then use the Target property of the Mouse object which gets whatever object the mouse is looking at.

In a LocalScript inside the tool, here's an example:

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

tool.Activated:Connect(function()
	if mouse.Target.Name == "PartThatWillGoInvisible" then
		mouse.Target.Transparency = 1
	end
end)

The above script will set any Part that has the name PartThatWillGoInvisible to be invisible.

Hope this helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.