Here's the code I did (it's in a LocalScript in StarterPlayerScripts):
01 | while wait( 1 ) do |
02 |
03 | local p = game.Players.LocalPlayer |
04 | local m = p:GetMouse() |
05 |
06 | if m.Target.Name = = "Terrain" then |
07 |
08 | print (m.Target) -- Here is where I want something like m.Target.TerrianMaterial |
09 |
10 | else |
11 |
12 | print (m.Target) |
13 |
14 | end |
15 |
16 | end |
I want it to print "Stone" or "Mud" if the mouse target is pointing to "Stone" or "Mud" (just an example).
Is this possible?
Ignore my previous post, this works.
This one does it every 2 seconds.
1 | local RunService = game:GetService( "RunService" ) |
2 | local p = game.Players.LocalPlayer |
3 | local m = p:GetMouse() |
4 | while true do |
5 | wait( 2 ) --change this to anything you like |
6 | if m.Target and m.Target:IsA( "BasePart" ) then |
7 | print (m.Target.Material) |
8 | end |
9 | end |
This one does it once:
1 | local RunService = game:GetService( "RunService" ) |
2 | local p = game.Players.LocalPlayer |
3 | local m = p:GetMouse() |
4 | wait( 2 ) --change this to anything you like |
5 | if m.Target and m.Target:IsA( "BasePart" ) then |
6 | print (m.Target.Material) |
7 | end |