Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Indicate when someone puts their mouse over a part?

I've seen interact tools and all that, like where you put your mouse over a part it shows up a gui saying "Click to interact." (Which is something I actually want)

But how does the script know when the mouse is on it?

What event do you need to put down for it?

I WANT IT IN A PART

1 comment

0

Is my expertise needed? Or are you satisfied with the answers you already have?

3 answers

In addition to TurboFusion's answer, you can also use SurfaceGuis. Put that in a PlayerGui, set the Adornee property to the brick you want, put a Frame in the SurfaceGui, and listen for the Frame's MouseEnter event.

Generally, it's better to use an event than to use an infinite loop (loops take more processing time, whereas the event will only run your code when you need it).

You can't use the script in a part it has to be in a local script because only local scripts can get the players' mouse. But if you want the GUI to pop up only for a specific part you can like so:

if Mouse.MouseTarget.Name == "food" then
--Make "Click to eat GUI here"
end
end

There is a Property in the Mouse Called Target this can be used to detect if the Mouse is Hovering over an Object, but in this case, you want it to be a Certain Object, And note that any of the Mouse's Properties, Functions, and Events can ONLY ran on a LocalScript, Now to your script:

mouse=game.Players.LocalPlayer:GetMouse()--We'll start with a GetMouse

while mouse do--you can change it to while true do
	wait()--you must add a wait in order to prevent Crashes
	if mouse.Target==workspace.PARTNAME then
		print("part")
	end
end

-- [ [OUTPUT] ] = part

If this helped please Accept answer and Upvote!

This discussion is preserved as it was. New answers, comments, and votes are closed.