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

Check what Terrain is touched?

Asked by 9 years ago

I don't know if it's possible to check what terrain type is touched, but if so, would this be to check?

script.Parent.RightLeg.Touched:connect(function(hit)
    if hit.Material == Enum.Material.Slate then
        -- stuff
    end
end)
0
I think you can't work with terrain like that. It's kind of a whole in workspace, you gotta put your own bricks to script with KoreanBBQ 301 — 9y
0
I think that's what he's aiming for, kindof like brick-material, and not game Terrain... If so, then just print in the output print("Player has touched on Slate") and so on... Xetrax 85 — 9y

2 answers

Log in to vote
2
Answered by
KoreanBBQ 301 Moderation Voter
9 years ago

GetCell()

CellMaterial, CellBlock, CellOrientation GetCell ( int x, int y, int z ) Returns the material, type, and orientation of grid cell (x, y, z).

^From the wiki

You could call that method when your character is touching the Terrain, and getting the Cell doing Character.Torso.Position.Y-4 or something.

GetCell() will return the Material of the Cell.

0
Et voila. Nice one :) DragonODeath 50 — 9y
Ad
Log in to vote
0
Answered by
Xetrax 85
9 years ago

If you're not aiming for game terrain, then this should do:

script.Parent.RightLeg.Touched:connect(function(hit)
    print(script.Parent.Name .." has touched ".. hit.Material)  --Easy fix, just be sure to have the Output window open in studio. (Found in the View tab.)
end)

Hope that helps!

Answer this question