Ok, so I am trying to make a mining game that uses terrain, and I want the speed of the mining to be based off of the material of the terrain. the only problem is…
script.Parent.Touched:Connect(function(Touch)
if Touch:IsA("Terrain") then
if Touch.Material == Enum.Material.Plastic then -- But it's salt
print("Every single terrain material output is plastic, even though it is not.")
-- This makes it very hard to find the material of terrain.
end
end
end)
I feel like this should be working, but you should check if its the terrain material that you said it was. if its still the same then i dont know how to help you as i am not experienced with terrain scripting.
You most likely need to do a raycast from one of the body parts of your character and a few studs forward.
I’d recommend learning here how to use Raycasting, for the direction of the ray you need to use the LookVector of the body part’s CFrame multiplied by a distance it checks, 3-5 would be ideal for you
Touched only really works for parts, it doesn’t work well for Terrain
Though raycasting constantly when a part touches would be expensive so you should probably make it raycast after activating the tool through the Activated event