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
8 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?

local surf = mouse.TargetSurface
            if surf == "0" then
                print("Right")
            elseif surf == "1" then
                print("Top")
            elseif surf == "2" then
                print("Back")
            elseif surf == "3" then
                print("Left")
            elseif surf == "4" then
                print("Bottom")
            elseif surf == "5" then
                print("Front")
            else
                print("Error")
            end

1 answer

Log in to vote
0
Answered by 8 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

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

NUMBER

local Surface = mouse.TargetSurface
if Surface == 5 then
    print("Front")
end

STRING

local Surface = mouse.TargetSurface
if Surface == "Front" then
    print("Front")
end

Hope this helped!

Ad

Answer this question