Raycasting is detecting terrain materials as 'plastic'?

hey guys, what’s up, :slight_smile: basically, I’ve been having a trouble… I am raycasting to check if player is driving trough terrain, but it always print plastic(material) when the hit part is terrain
code;

	local char = player.Character
	if (char) then
		local humRoot = char.HumanoidRootPart
		if (humRoot) then
			if (humRoot.Velocity.Magnitude <= 10) then
				return
			end
			local para = RaycastParams.new()
			para.FilterDescendantsInstances = {workspace.Terrain,workspace.Map}
			para.FilterType = Enum.RaycastFilterType.Whitelist
			local ray = workspace:Raycast(humRoot.Position,humRoot.CFrame.UpVector*-40,para)
			if (ray) then
				if (ray.Instance) then
					if (ray.Instance == workspace.Terrain) then
						print(ray.Instance.Material)
						if (settings.AllowedTerrain[ray.Instance.Material]) then
							if (respawners[player]) then
								respawners[player] = nil
							end
							return
						end
						if (respawners[player]) then
							return
						end
						print('set respawn')
						respawners[player] = os.time()
					end
				end
			else
				if (respawners[player]) then
					respawners[player] = nil
					return
				end
			end
		end
	end

Any idea?

It’s in a loop.

Video;

3 Likes

as far as I know, Plastic is not a material from terrain :flushed:

Interesting, I think a better place for this would be #platform-feedback:studio-bugs

2 Likes

I don’t think it’s a bug, it’s somehow printing plastic idk why

it is either a bug, or you messed something up in your script with the “material” printing. This wouldn’t be efficient, but if you haven’t already, I recommend using if statements for the different materials it could be detecting. Example:

if material == “Grass” then
print(“Grass”)

Terrain materials, as all materials have they own class in Enum.Materials
So, that won’t work

Gotcha, I recommend still going to #platform-feedback:studio-bugs and getting it checked out. The worst thing that could happen is it not being a bug and you get help.

Sure, but I can’t post there yet.

Oof, good luck! I hope you get this solved.

1 Like

Firstly, try this:
Go on concrete (A block, not terrain), what does it print?
Go on plastic, what does it print?
Please answer these and I think I can help.

I think the main issue is with terrain, but if it doesn’t work with normal parts than I think its something wrong with their script.

hey, sure, well, nothing much, it prints the part as its meant to, and when you go to terrain, pip, it prints material’s plastic :gorilla:


bruh

I have no clue what’s causing this, maybe we can @ staff or something

If someone knows, please

help :smiley:

Maybe try that. Maybe tell someone who has access to #platform-feedback:studio-bugs to post something about this there. Staff like to check out the Studio Bugs area quite a bit.

I’m pretty sure this isn’t supposed to happen, I guess it’s a bug and you can’t do anything to fix it :man_shrugging:

Hi, I hope what I say helps. I found a similar thread where someone was trying to print out the material but it also returned as plastic
https://devforum.roblox.com/t/detecting-the-material-of-terrain-with-a-touched-function/299830/3

In this post, a Roblox staff member suggested checking out Humanoid.FlootMaterial in the API reference. Heres the link to that: https://developer.roblox.com/en-us/api-reference/property/Humanoid/FloorMaterial

Hey, I have to check what’s under a part… so that will be hard :frowning:

Anyone knows any solution to this D:

Try to visualize your rays by materializing them into short lifetime parts.

Or create a non-collision part to show the ray’s end position

(to debug)

I don’t think I should try that… since, Instance == workspace.Terrain returns true so, hmm if it wasn’t the hitpart terrain, it wouldn’t return true

1 Like