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

Need help completing my system?

Ok, so recently. i made a thing where the humanoidrootpart teleports to where ever your mouse is. i want to know. How can i know if the mouse isn't pointing towards the air.

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

if mouse.Target ~= Enum.Material.Air then
print('...')
end

This is a demonstration. i need help understanding how to go MORE on this. Please. Help.

1 answer

✓ Accepted answer

Mouse.Target refers to the BasePart that the Cursor is currently hovering over. As you would have experienced in your program, if it is pointing towards anything but it will read nil. That already is enough information to determine a denounce for "pointing" at the Sky:

if (Mouse.Target) then
	--// Code..
end

1 comment

0

Thank you.

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