Welding an object prevents bodyvelocity from working

I have code that shoots a projectile. It works great!


EDIT: I should note that they ARE moving like projectiles. They only seem to go away instantly because they’re moving very fast.

However, when I merge it with my hitbox script, it doesn’t.


EDIT: The red here is the hitbox; I left it in debug mode so they are visible for testing.

This is the code in my main script.

-- Create hitbox
			effects.CreateHitbox({Impact = {"Blood"}, Size = needle.Size * 2, CFrame = needle.CFrame, Bound = needle, ImmunePlayers = {plr.Name}, Damage = NEEDLE_DAMAGE,
				Duration = NEEDLE_LIFE, Stun = NEEDLE_STUN, Debug = DEBUG})
			
			-- Shoot needle
			effects.CreateProjectile(needle, NEEDLE_LIFE, target, NEEDLE_SPEED, NEEDLE_ACCELERATION)
			needle.Parent = game.Workspace

The relevant parts of my effects module are shown below:
effects.CreateHitbox

local hitbox = game.ReplicatedStorage.effectsParts.effectBlock:Clone()
		hitbox.Name = "hitbox"
		hitbox.CanTouch = true

		-- Create list of players that have been hit already
		local hitPlayers = Instance.new("Folder", hitbox)
		hitPlayers.Name = "hitPlayers"

		hitbox.Size = info["Size"]
		hitbox.CFrame = info["CFrame"]
		if info["Debug"] then
			hitbox.Transparency = .5
			hitbox.Color = Color3.fromRGB(255, 0, 0)
		end

if info["Bound"] then
			hitbox.Anchored = false
			local weld = Instance.new("WeldConstraint")
			weld.Part0 = hitbox
			weld.Part1 = info["Bound"]
			weld.Parent = weld.Part0
			hitbox.Parent = info["Bound"]
		else
			hitbox.Parent = game.Workspace
		end

effects.CreateProjectile

-- Create velocity
	local attachment = Instance.new("Attachment", projectile)

	local vel = Instance.new("BodyVelocity")

	local base = (aim - projectile.CFrame.Position).Unit
	vel.Velocity = base
    vel.Parent = projectile

The effectsParts.effectBlock, by the way, is Massless, as is the needle projectile.
Both of these scripts work fine in isolation, for the record.

Why isn’t it moving like it should? How do I fix it?

Setting max force to (1e6, 1e6, 1e6) works, but I’m not sure why, since everything is massless. If someone could explain, that’d be nice!

1 Like

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