This is a bit of a tougher concept. There are however many ways to go at it.
The first way (my personal way) is to use the line mouse.Target.Name, put an if afterwards, and then have it hard coded to check for certain words. From there, you could then set a variable (in lighting, for instance) to a value if the name of the part equals a name in a table or list.
From there, add a repeat wait() until game.Lighting.variable.Value == true or a Changed event to run the designated code.
It will require being in a LocalScript, and will need mouse defined (local mouse = game.Players.LocalPlayer:GetMouse())
Or, if you're not looking for specifics, and just to check if it's a part, you could just do this --
if mouse.Target ~= nil then
end
Now, the second way is a bit more professional, however, it's definitely more complex. That way would be Raycasting. It's great with detecting parts and many other detection sources (best used with a tool of some sort). Here's a good wiki page for general Raycasting, and what looked to be a good Raycasting basics page to help you get started.
The first example in the basics might already be similar to what you're looking for.
I wouldn't fully suggest using these methods without it being a tool or a LocalScript inside of StarterGui, but maybe there's a workaround I'm not thinking of at the moment.
Those are what I believe to be the best ways to check for parts, as both have their strengths and weaknesses. I'm sure there are more, but they're either inferior to both listed above, or I'm not aware of them.
If you have any other questions, feel free to ask, and I'll answer to the best of my knowledge. Good luck in your endeavors!
4 comments
Here is my question, since this is a Local Script, would it be possible to have it so when someone hovers their mouse over a part, it modifies a brick inside of Workspace?
Most likely, what kind of modification are we talking?
A gate opening or a door opening
That would work just fine. I'd suggest making a boolean variable, placing it somewhere, and making the "part" script set it to true. The gate could then have a non-local script that listens for when the bool value is either changed or == true.