What is the simplest way to detect if an object is left clicked? I'd like it to work exactly like a click detector except without it detecting right clicks. Whenever someone moves the camera on my game, the blocks act like someone clicked them.
You can use a property of Mouse called Target. Target represents a BasePart the mouse is currently hovering over. You can get this target by implementing it in a mouse button event. Here's an example using UserInputService:
-- Get game services local InputService = game:GetService("UserInputService") local Players = game:GetService("Players") local Player = Players.LocalPlayer local Mouse = Player:GetMouse() -- Get the player mouse -- Maybe make some references to the input type enums local UserInput = Enum.UserInputType local KeyCode = Enum.KeyCode InputService.InputBegan:connect(function(Input) local User = Input.UserInputType local Key = Input.KeyCode if User == UserInput.MouseButton1 then print(Mouse.Target) -- Print the object the mouse left clicked on end end)
That should print the name of any object you left-click on. Remember, Mouse.Target returns the actual object of whatever the mouse is currently hovering over. If you have any questions, just let me know.