I need help with making a part get cloned with an offset of the players torso

I need the bullet to have an offset to the players right arm

this is a video of the ability being used. I need the bullet to come out of the barrel of the gun instead of the torso.

I tried making it come out of the gun but the bullet flew left instead of in front of the character

Here’s the code for my bullet:

local bullet = game:GetService("ServerStorage").Bullet
bullet.CanCollide = false
local bulletSpeed = 150
local bulletifetime = 1
local bulletDamage = 75
local canshoot = true
game.ReplicatedStorage.Sand.Gun1.OnServerEvent:Connect(function(player)
	local humanoid = player.Character.Humanoid
	local AnAnimation = game.Workspace.Animations.Sand.Shoot
	local animTrack = humanoid:LoadAnimation(AnAnimation)
	animTrack:Play()
	local char = player.Character
	local hrp = char.Torso


	local root = hrp

	local bv = Instance.new("BodyVelocity")
	bv.MaxForce = Vector3.new(1,1,1) * 30000
	bv.Velocity = root.CFrame.lookVector * bulletSpeed

	local fb = bullet:Clone()
	fb.Parent = game.Workspace
	fb.CFrame = root.CFrame
	bv.Parent = fb

	game.Debris:AddItem(fb,bulletLifetime)

	fb.Touched:Connect(function(hit)
		if hit.Parent.Name ~= player.Name then
			if hit.Parent:FindFirstChild("Humanoid") then
				print("bullet has hit", hit.Name)
				hit.Parent.Humanoid:TakeDamage(20)
				fb:Destroy()

			end
		end
	end)
end)

Thanks for reading :smile:

Offset the CFrame, and preferably use the gun or arm’s CFrame instead of the torso.

local rightArm = char:FindFirstChild("Right Arm")

if rightArm then
	local cf = rightArm.CFrame * CFrame.new(0, -1.5, 0)
	--Rest of the code
end

I’m checking if the character has a right arm first, incase they were in the middle of a respawn, or fell into the void thus their character was deleted, so the script doesn’t error.

1 Like

I came up with my own solution
i made a part spawn on the arm, get welded to the humanoid root part, made it invisible and set the root to it. Thanks for the help tho :slight_smile:

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