This is in local script.
local Tool = script.Parent local UserInputService = game:GetService("UserInputService") Tool.Equipped:Connect(function() if UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1)== true then print("yay") end end)
i know this might be noob question but pls help
You'll need to use InputBegan. Example:
local UIS = game:GetService("UserInputService") -- Getting the service function Began(Input) -- Function, input is the key typed if Input.UserInputType == Enum.UserInputType.MouseButton1 then -- Checking if the key pressed was MouseButton1 aka. left click print("Clicked!") end -- Ends if statement end -- Ends function UIS.InputBegan:Connect(Began) -- The event for InputBegan
Or, you can use Activated, which is a lot more simple.
function Clicked() -- Function print("Clicked!") -- Prints out "Clicked!" end -- Ends function script.Parent.Activated:Connect(Clicked) -- The event for Activated, aka. when a player presses left click
Hope this helps!