You can use Unequiped and Equppied and see that if the tool is equipped, and you click the block, it will do something, but if it is unequipped and you click the block, nothing will happen.
Or if you were looking for a different way other people will assist you.
ex:
game.StarterPack.Tool.Equipped:Connect(function()
game.Workspace.Block.ClickDetector.MouseClick:Connect(function()
print("yay it worked tool was equipped on press")
-- other stuff
game.StarterPack.Tool.Unequipped:Connect(function()
game.Workspace.Block.ClickDetector.MouseClick:Connect(function()
print("didn't work tool needs to be equipped")
end)
end)
end)
end)
EDIT: thereâs probably a batter approach to this problem I am not aware of, other people can help
What do you want to happen when you click on the part?
You could do something like this:
local script in tool
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
script.Parent.Set:FireServer(mouse.Target)
end)
script in tool
Set.OnServerEvent:Connect(function(player,Target)
if Target and Target.Name == "name of your part" then
print ("stuff happens")
end)
Why would you call the tool from the starter pack? You can simply call it from the players inventory. An example would be:
local plr = game.Players.LocalPlayers
local tool = plr.Backpack.ToolName
Also, when you have a tool, you canât use click detectors. Why? I have no idea. But, you can detect the position of the mouse and go on from there. I hope this helps . Iâm sure there are many tutorials on mouse.hit.
If you use a click detector, just insert a script inside of the click detector and write this:
script.Parent.MouseClick:Connect(function(player)
local Character = player.Character
if Character:FindFirstChild("INSERT_TOOL_NAME") then
-- Do what you want here!
end
end
Just replace the INSERT_TOOL_NAME with your tool name. When a player holds a tool, it goes under the character so thatâs why were are looking for the tool inside there.
The only error is this [12:05:51.301 - Players.octavodad.Backpack.ToolThatClickBlock.Script:4: Expected identifier when parsing expression, got â)â]
Set = script.Parent.Set
Set.OnServerEvent:Connect(function(player,Target)
if Target and Target.Name == "name of your part" then
print ("stuff happens")
end
end)