Vİewmodel Bullets not being able accurate with the characters bullets

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to make the bullets come out of the guns(characters holding) to be the same as the viewmodels. Note: I still didnt add the bullets come out from character because Im not sure how to exactly do it as I said.)

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? I couldnt find anything because I didnt know how to corretly search about it

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

anyone got a idea ? ? ? !!! … sad

You’ll add an attachment near the front of the barrel. The bullet’s CFrame will then be aligned with the attachment’s CFrame. From there, you can apply an impulse to the bullet in the direction of its lookvector

Yes but it wont be aligned on the viewmodel-player(depends on the which one firing which one)

Okay, well, your gonna need to share some code so I can see what ur doing

local module = {}

local DamageEvent = game:GetService("ReplicatedStorage").Events.BulletDamage

function module(player, gun, endposition)
	local gunConfig = require(gun.Config)
	local BulletVelocity = gunConfig.bulletVelocity
	local BulletDamage = gunConfig.bulletDamage
	local Barrel = gun.Barrel

	local Bullet = Instance.new("Part")
	Bullet.Size = Vector3.new(0.2,0.2,0.5)
	Bullet.Anchored = true
	Bullet.CanCollide = false
	Bullet.Color = Color3.new(1, 0.92549, 0.0980392)
	Bullet.Material = Enum.Material.Neon
	Bullet.Parent = game.Workspace

	Bullet.CFrame = CFrame.new(Barrel.Position, endposition)

	local Loop

	Loop = game:GetService("RunService").RenderStepped:Connect(function(deltaTime)
		local Hit = workspace:Raycast(Bullet.Position, Bullet.CFrame.LookVector * BulletVelocity * 1.5)
		if Hit then
			if Hit.Instance.Parent:FindFirstChild("Humanoid") and DamageEvent ~= nil and Hit.Instance.Parent.Name ~= player.Name then
				DamageEvent:FireServer(Hit.Instance.Parent, BulletDamage)
				Loop:Disconnect()
				Bullet:Destroy()
			else
				Loop:Disconnect()
				Bullet:Destroy()
			end
		end
		Bullet.CFrame *= CFrame.new(0, 0, -BulletVelocity * (deltaTime * 60))
	end)
end

return module

client side on viewmodel. (İt gives damage on the server but rn it doesnt matter). I want the gun on the character to be aligned with the bullet with viewmodels bullet. How do I make them shoot the same bullet on the same position?

try this

local module = {}

local DamageEvent = game:GetService("ReplicatedStorage").Events.BulletDamage

function module(player, gun, endposition)
	local gunConfig = require(gun.Config)
	local BulletVelocity = gunConfig.bulletVelocity
	local BulletDamage = gunConfig.bulletDamage
	local Barrel = gun.Barrel

	local Bullet = Instance.new("Part")
	Bullet.Size = Vector3.new(0.2,0.2,0.5)
	Bullet.Anchored = false
	Bullet.CanCollide = false
	Bullet.Color = Color3.new(1, 0.92549, 0.0980392)
	Bullet.Material = Enum.Material.Neon
	Bullet.Parent = game.Workspace

	Bullet.CFrame = Barrel.CFrame

	local Loop

	Loop = game:GetService("RunService").RenderStepped:Connect(function(deltaTime)
		local Hit = workspace:Raycast(Bullet.Position, Bullet.CFrame.LookVector * BulletVelocity * 1.5)
		if Hit then
			if Hit.Instance.Parent:FindFirstChild("Humanoid") and DamageEvent ~= nil and Hit.Instance.Parent.Name ~= player.Name then
				DamageEvent:FireServer(Hit.Instance.Parent, BulletDamage)
				Loop:Disconnect()
				Bullet:Destroy()
			else
				Loop:Disconnect()
				Bullet:Destroy()
			end
		end
		Bullet:ApplyImpulse(Barrel.CFrame.LookVector * 100) -- * gunConfig.bulletVelocity?
	end)
end

return module

Noo like how do I align the viewmodels Bullets with characters. It doesnt have a scripting issue

Sorry lol I don’t understand what your talking about


Think like both are holding(animated) and when I shoot(bullet goes out from viewmodel and the bullet goes out from the marked area) the bullet is not aligned with the characters guns barrel(I marked on the blue)

If u want to move the bullet closer u just do

Bullet.CFrame = Barrel.CFrame * CFrame.new(-Barrel.CFrame.lookVector * distance_to_move)

I just checked where the bullet comes out and its pretty accurate so I didnt needed to change anything but thanks

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