Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you check part of the terrains material?

So I'm working on something similar to the Frost Walker boots from Minecraft, for my game Sorcery, but I came across this problem.

I have no way of telling if the player is walking on water, or on ice.

If I ever wanted to check if the player was touching water before, I just checked if what it hit was the terrain object, but now I have no way to distinguish between Ice or Water.

Right now, the player just goes flying up, creating hilariously interesting towers.

However, this is not my intended behaviour.

Is there any easy way of checking the material of a specific part of the terrain?

And just in case you were wondering, if you check the material property of the terrain, no matter where you hit it from, it just returns Plastic.

(Roblox is made of plastic confirmed?)

Code:

	
	char = script.Parent
	
	repeat wait() until char.Head
	
	print'START'
	
	while wait() do
		local ray = Ray.new(
	    char.Head.CFrame.p,                           		 -- origin
	    ((char.Head.CFrame.p - Vector3.new(0,1,0)) - char.Head.CFrame.p).unit * 500 -- direction
		) 
		
		local ignore = char
		
		local hit, position, normal = workspace:FindPartOnRay(ray, ignore)
		
		if hit == workspace.Terrain then
			workspace.Terrain:FillBall(position,3,Enum.Material.Ice)
			spawn(function() wait(2) workspace.Terrain:FillBall(position,3,Enum.Material.Water) end)
		end
		
	end

Additional links:

http://wiki.roblox.com/index.php?title=API:Class/Terrain https://www.roblox.com/games/1293192884/Sorcery-Alpha

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.