Hello;
I am working on car, and the map consists of Smooth Terrain.
So I want to add dirt trails behind the wheels whenever driving on Terrain Grass, Mud etc.
How would I go about it; To clarify I already fixed the trails I just need to know when to enable and disable the trails.
The current script I got:
game["Run Service"].Heartbeat:Connect(function()
if script.Parent.Parent.Parent.Stats.Engine.Value == false then return end
local ray = Ray.new(script.Parent.Position,(script.Parent.Position - Vector3.new(0,-1,0)).unit * 3.5)
local new = Instance.new("Part", workspace.Terrain)
new.Material = Enum.Material.Neon
new.Anchored = true
new.CanCollide = false
local _, pos, _, Material = workspace:FindPartOnRayWithIgnoreList(ray, {new, script.Parent, script.Parent.Parent.Holder, script.Parent.Parent.Axel, script.Parent.Parent.Parent.Engine})
local distance = (script.Parent.CFrame.Position - pos).magnitude
new.Size = Vector3.new(.1,.2,distance)
new.CFrame = CFrame.new(script.Parent.CFrame.Position, pos) * CFrame.new(0, -distance, 0)
print(Material)
if Material == Enum.Material.Grass or Material == Enum.Material.Mud or Material == Enum.Material.LeafyGrass or Material == Enum.Material.Ground then
script.Parent.Trail.Enabled = true
else
script.Parent.Trail.Enabled = false
end
game:GetService("Debris"):AddItem(new, 3)
end)
The trail is attached to the 2 Trail Attachments.
Right now the script just outputs the Air Material.
I have tried to change the Vector3 offset to different values but it still dosen’t work.
(On line 3)