Issue about the deviation of the grenade landing point

I’m currently making a grenade launcher.
I’m trying to complete a grenade that appears when I click on it, but when I try to explode at the grenade’s landing point, the landing point often shifts. I’ve tried both BasePart.Touched and FindPartOnRay, but both have their drawbacks and sometimes don’t work.

Example of drawbacks :

The script that has issue :

ignore = {}
alreadyexploded = false

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr, mousehitpos)
	alreadyexploded = false
	local Bullet = Instance.new("Part")
	Bullet.Size = Vector3.new(0.5, 0.5, 0.75)
	Bullet.Parent = game.Workspace
	Bullet.Position = script.Parent.BulletGoes.Position
	Bullet.CanCollide = false
	Bullet.Anchored = false
	Bullet.CFrame = CFrame.new(Bullet.Position, mousehitpos)
	Bullet.BrickColor = BrickColor.Black()
	local raychecker = script.Parent.ok:Clone()
	raychecker.Parent = Bullet
	raychecker.Disabled = false
	local velocity = Instance.new("BodyVelocity")
	game:GetService("Debris"):AddItem(velocity,0.1)
	velocity.Parent = Bullet
	velocity.Velocity = Bullet.CFrame.LookVector * 150
	Bullet.Touched:Connect(function(hit)
		if hit.CanCollide == true and not hit.Parent:IsA("Tool") or hit.Parent:FindFirstChild("Humanoid") or not hit.Parent == plr.Character then
			if alreadyexploded == false then
				alreadyexploded = true
				wait(0.01)
				Bullet.Anchored = true
			local positionofexplode = Instance.new("Part")
			game:GetService("Debris"):AddItem(positionofexplode,2)
			positionofexplode.Transparency = 1
			positionofexplode.CanCollide = false
			positionofexplode.Anchored = true
			positionofexplode.CollisionGroupId = 3
			positionofexplode.Size = Vector3.new(0.5,0.5,0.5)
			positionofexplode.Parent = game.Workspace
				positionofexplode.Position = Bullet.Position
				Bullet:Destroy()
			local boom1 = game.ServerStorage.Boom1
			local boom2 = game.ServerStorage.Boom2
			local cloneboom2_1 = boom2:Clone()
			game:GetService("Debris"):AddItem(cloneboom2_1,10)
			cloneboom2_1.Parent = game.Workspace
			cloneboom2_1.Position = Vector3.new(positionofexplode.Position.X + math.random(-4,4), positionofexplode.Position.Y + math.random(0,4), positionofexplode.Position.Z + math.random(-4,4))
			local cloneboom2_2 = boom2:Clone()
			game:GetService("Debris"):AddItem(cloneboom2_2,10)
			cloneboom2_2.Parent = game.Workspace
			cloneboom2_2.Position = Vector3.new(positionofexplode.Position.X + math.random(-4,4), positionofexplode.Position.Y + math.random(0,4), positionofexplode.Position.Z + math.random(-4,4))
			local cloneboom2_3 = boom2:Clone()
			game:GetService("Debris"):AddItem(cloneboom2_3,10)
			cloneboom2_3.Parent = game.Workspace
			cloneboom2_3.Position = Vector3.new(positionofexplode.Position.X + math.random(-4,4), positionofexplode.Position.Y + math.random(0,4), positionofexplode.Position.Z + math.random(-4,4))
			local cloneboom2_4 = boom2:Clone()
			game:GetService("Debris"):AddItem(cloneboom2_4,10)
			cloneboom2_4.Parent = game.Workspace
			cloneboom2_4.Position = Vector3.new(positionofexplode.Position.X + math.random(-4,4), positionofexplode.Position.Y + math.random(0,4), positionofexplode.Position.Z + math.random(-4,4))
			local cloneboom2_5 = boom2:Clone()
			game:GetService("Debris"):AddItem(cloneboom2_5,10)
			cloneboom2_5.Parent = game.Workspace
			cloneboom2_5.Position = Vector3.new(positionofexplode.Position.X + math.random(-4,4), positionofexplode.Position.Y + math.random(0,4), positionofexplode.Position.Z + math.random(-4,4))
			local cloneboom2_6 = boom2:Clone()
			game:GetService("Debris"):AddItem(cloneboom2_6,10)
			cloneboom2_6.Parent = game.Workspace
			cloneboom2_6.Position = Vector3.new(positionofexplode.Position.X + math.random(-4,4), positionofexplode.Position.Y + math.random(0,4), positionofexplode.Position.Z + math.random(-4,4))
			local cloneboom2_7 = boom2:Clone()
			game:GetService("Debris"):AddItem(cloneboom2_7,10)
			cloneboom2_7.Parent = game.Workspace
			cloneboom2_7.Position = Vector3.new(positionofexplode.Position.X + math.random(-4,4), positionofexplode.Position.Y + math.random(0,4), positionofexplode.Position.Z + math.random(-4,4))
			local cloneboom2_8 = boom2:Clone()
			game:GetService("Debris"):AddItem(cloneboom2_8,10)
			cloneboom2_8.Parent = game.Workspace
			cloneboom2_8.Position = Vector3.new(positionofexplode.Position.X + math.random(-4,4), positionofexplode.Position.Y + math.random(0,4), positionofexplode.Position.Z + math.random(-4,4))
			--local explode = Instance.new("Explosion")
			--game:GetService("Debris"):AddItem(explode,2)
			--explode.BlastRadius = 15
			--explode.BlastPressure = 120000
			--explode.DestroyJointRadiusPercent = 0
			--explode.Visible = false
			--explode.Parent = game.Workspace
			--explode.Position = Target.Position
			local cloneboom1 = boom1:Clone()
			game:GetService("Debris"):AddItem(cloneboom1,3)
			cloneboom1.Grenade_explode:Play()
			cloneboom1.Parent = game.Workspace
			cloneboom1.Position = positionofexplode.Position
			local boomcore = game.ServerStorage.Boomed:Clone()
			game:GetService("Debris"):AddItem(boomcore,0.2)
			boomcore.Parent = game.Workspace
			boomcore:SetPrimaryPartCFrame(positionofexplode.CFrame)
			end
		else
			
		end--end
	end)
end)

How can I prevent the landing point from shifting?
Thank you.

1 Like

I think it’d be more understood if you also displayed your block of code