Hello, well that I want the particles of fire to be deactivated when it touches the ground, I have tried many ways, but without result, how could I do it? I'm very stuck Thank you

local UserInputService = game:GetService("UserInputService")
local ground = game.Workspace.ground
local car = game.Workspace.car
local sound = Instance.new("Sound", script.Parent)
sound.Name = "engine"
sound.SoundId = "rbxassetid://532147820"
local wheel1 = game.Workspace.car["FrontR"]
local wheel2 = game.Workspace.car["FrontL"]
local mult = 1.30 
local maxpitch = 3.00 
local idlespeed = 1 
local debounce = false
local fire = game.Workspace.car.fire.Fire
fire.Enabled = false


if car.PrimaryPart ~= nil then
	
	car.PrimaryPart.Touched:Connect(function(touched)
		if touched.Parent ~= nil then
			UserInputService.InputBegan:Connect(function(input)
				if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D or input.KeyCode == Enum.KeyCode.Up or input.KeyCode == Enum.KeyCode.Left or input.KeyCode == Enum.KeyCode.Right then
					fire.Enabled = true
				end
			end)
			UserInputService.InputEnded:Connect(function(inputEnd)
				if inputEnd.KeyCode == Enum.KeyCode.W or inputEnd.KeyCode == Enum.KeyCode.A or inputEnd.KeyCode == Enum.KeyCode.D or inputEnd.KeyCode == Enum.KeyCode.Up or inputEnd.KeyCode == Enum.KeyCode.Left or inputEnd.KeyCode == Enum.KeyCode.Right then
					fire.Enabled = false
				end
			end)
		end
	end)
				
end


car.PrimaryPart.Touched:Connect(function(touch)
	if touch then
		if touch.Parent ~= ground then
			print("false")
			sound:Play()
			sound.Looped = true
			sound.Volume = 1
			while true do
				wait (0.05)
				local wlsp = ((wheel2.RotVelocity + wheel1.RotVelocity)/2).magnitude
				local wlsp2 = ((wlsp / 200) + idlespeed) * mult
				if wlsp2 < maxpitch then
					sound.Pitch = wlsp2
				else
					sound.Pitch = maxpitch
				end
			end
		end
	end
end)
ground.Touched:Connect(function(touch)
	if not debounce then
		debounce = true
		
		if touch then
			if touch.Parent ~= car then
				print("true")
				sound:Stop()				
				
			end
			
		end
		wait(2)
		debounce = false
		
	end
end)

2 comments

0

Does the car hit the same place on the ground every time? Or is the ground a part/model by chance?

0

The car the PrimaryPart is a VehicleSeat and the floor is Part that comes by default only if you change the name. and only the car collides once.