Why does this not work?

I am currently trying to script a tool so when you click on a part with it equipped, it prints something. But otherwise, if you click it when it is not equipped, I want nothing to print.
Local script in tool

local player = game.Players.LocalPlayer
local tool = script.Parent
Set = game.ReplicatedFirst.Set
local Target = game.Workspace.Block



tool.Equipped:Connect(function(mouse)
	mouse.Button1Down:Connect(function()
		if mouse.Target and mouse.Target.Parent then
		end
	end)
end)

tool.Activated:Connect(function()
    Set:FireServer(Target, tool)
end) 

player.MouseButton1Click:Connect(function()
    Set:FireServer(Target, tool)
end) 

Script in tool

local player = game.Players.LocalPlayer
local tool = script.Parent
Set = game.ReplicatedFirst.Set
local Target = game.Workspace.Block

Set.OnServerEvent:Connect(function(player, Target, tool)
      if Target == "Block" and tool.Eqquiped == true then
          print ("stuff happens")
      end
end)

Thanks

1 Like

You did not get the player’s mouse…

Oh silly me. will do now 30 chars

Did you get any errors in the console?..

Yeah [13:07:58.182 - MouseButton1Click is not a valid member of Player]

By the way, ReplicatedFirst is not meant to store remotes. You have confused it with ReplicatedStorage. The former is meant for LocalScripts, whereas the latter is meant for replicating contents between the server and client.

1 Like
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
    -- Code...
end)

I only want the thing to print when you click the part with a certain tool though.

Mabye use the tool.Activated function instead if you want to use it on a specific tool

You could name the tool something different to differentiate between tools then do the following:

tool.Activated:Connect(function()
     if tool.Name == "SpecificToolName" then --- checks to see for correct tool
         Set:FireServer(Target, tool)
     end
end)
1 Like

octavodad_support.rbxl (19.6 KB)
There’s a Tool and RemoteEvent.

4 Likes

OMG thankyou so much it works bro!

1 Like