PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

TargetSurface

Mouse

NormalId

This property indicates the Enum/NormalId of the BasePart surface at which the mouse is pointing. This property is derived from the world position of mouse (Mouse/Hit) and the part toward which the mouse is pointing (Mouse/Target).

This property isn’t meaningful when the mouse is not pointing at a part, for example when the mouse is pointing at the sky. At the moment, this property is set to ‘Right’ under these circumstances. Before using this property, check that the mouse’s target is not nil.

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
-- Check that there exists a part at which the mouse is pointing
if mouse.Target then
	print("The mouse is pointing to the " .. mouse.TargetSurface.Name .. " side of " .. mouse.Target.Name)
else
	print("The mouse is not pointing at anything.")
end


Code Samples


Surface Randomizer

The code in this sample, when placed in a LocalScript inside StarterPlayerScripts will set the surface of any BasePart clicked on to a random surface.