I am trying to make rotate something according to the surface of the part the mouse clicks, but I have no idea what output it gives! I have tried both strings and values but I end up having it print "Error". Anyone who can help me?
01 | local surf = mouse.TargetSurface |
02 | if surf = = "0" then |
03 | print ( "Right" ) |
04 | elseif surf = = "1" then |
05 | print ( "Top" ) |
06 | elseif surf = = "2" then |
07 | print ( "Back" ) |
08 | elseif surf = = "3" then |
09 | print ( "Left" ) |
10 | elseif surf = = "4" then |
11 | print ( "Bottom" ) |
12 | elseif surf = = "5" then |
13 | print ( "Front" ) |
14 | else |
15 | print ( "Error" ) |
16 | end |
The mouse.TargetSurface
property returns a NormalId
Enum, which has 6 Enums:
Right (0), Top (1), Back (2), Left (3), Bottom (4), and Front (5)
When you want to see what surface that the property returns, either compare it to the Enum, the number, or the string. Here are examples of each:
ENUM
1 | local Surface = mouse.TargetSurface |
2 | if Surface = = Enum.NormalId.Front then |
3 | print ( "Front" ) |
4 | end |
NUMBER
1 | local Surface = mouse.TargetSurface |
2 | if Surface = = 5 then |
3 | print ( "Front" ) |
4 | end |
STRING
1 | local Surface = mouse.TargetSurface |
2 | if Surface = = "Front" then |
3 | print ( "Front" ) |
4 | end |
Hope this helped!