Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

what is the mouse.TargetSurface output?

Asked by
sigve10 94
9 years ago

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?

01local 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

1 answer

Log in to vote
0
Answered by 9 years ago

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

1local Surface = mouse.TargetSurface
2if Surface == Enum.NormalId.Front then
3    print("Front")
4end

NUMBER

1local Surface = mouse.TargetSurface
2if Surface == 5 then
3    print("Front")
4end

STRING

1local Surface = mouse.TargetSurface
2if Surface == "Front" then
3    print("Front")
4end

Hope this helped!

Ad

Answer this question