Smoke effect problem

There is no problem when squeezing while standing in place, but when you squeeze while moving, the particles fly left and right.

Ekran Görüntüsü (11)
Ekran Görüntüsü (13)

-Script

local userInputService = game:GetService("UserInputService")


local player = Players.LocalPlayer

local tool = player.Backpack:WaitForChild("Tool") 


local isFiring = false
local fireRate = 0.1 



local AteslemeDumani = script.Parent.MuzzleSmoke.ParticleEmitter


local function fireBullet()
	local ammoFire = tool:FindFirstChild("AmmoFire")

	if ammoFire then


		while isFiring do
	
			local bullet = Instance.new("Part")
			bullet.Size = Vector3.new(0.5, 0.5, 2.5) 
			bullet.Position = ammoFire.Position + ammoFire.CFrame.LookVector * 2
			bullet.Parent = workspace
			bullet.BrickColor = BrickColor.new("Bright red") 


			local bodyVelocity = Instance.new("BodyVelocity")
			bodyVelocity.Velocity = ammoFire.CFrame.LookVector * 500
			bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			bodyVelocity.P = 1000 
			bodyVelocity.Parent = bullet

			bullet.CFrame = CFrame.lookAt(bullet.Position, bullet.Position + ammoFire.CFrame.LookVector)

			AteslemeDumani:Emit(1)

			bullet.Touched:Connect(function(hit)
				if hit:IsA("Player") then

				end
				bullet:Destroy()
			end)

			wait(fireRate)

		end
	else
		warn("AmmoFire nesnesi bulunamadı!")
	end
end


userInputService.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		isFiring = true
		fireBullet()
	end
end)


userInputService.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		isFiring = false
	end
end)
1 Like

ParticleEmitters have a variable that determines how much velocity it inherits from its parent when it is parent when it is emitted.

1 Like

Try enabling LockToPart. That should fix the problem.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.