hey guys, what’s up, 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
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:
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.
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.
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.