Vector force not working

I’ve been working on a gun that shoots little paintballs, I had the gun running on client, so the bullets didn’t show up for everyone. I then switched it over to server with remote events, and there are no errors in the output, but the bullets don’t travel. The movement method is a vector force.
Here is a video of what it looks like:

the scripts a bit long, but here it is:
local debris = game:GetService("Debris")
game.ReplicatedStorage.FireGun.OnServerEvent:Connect(function(player, mouseHit, gun)
	local function applyDrop(part, force, gun)
		local i = 1
		repeat 
			wait()
		until (part.Position - gun.Handle.Position).magnitude >= gun.Handle.MaxDistance.Value

		for i = 1, tonumber(gun.Handle.Drop.Value), 1 do
			wait()
			force.Force = Vector3.new(force.Force.X, force.Force.Y - i, force.Force.Z)
		end
	end
	
		local canDamage = true
		local part = Instance.new("Part")
		part.Shape = Enum.PartType.Ball
		part.Size = Vector3.new(0.5,0.5,0.5)
		part.Position = gun.Handle.GunTip.Position
		part.Material = Enum.Material.SmoothPlastic
		part.Color = Color3.fromRGB(255, 0, 0)
		

		local force = Instance.new("VectorForce")
		
		local ray = Ray.new(gun.Handle.Position, mouseHit - gun.Handle.Position)
		force.Force = ray.Unit.Direction * gun.Handle.Speed.Value
		print(force.Force)



		local attatchment = Instance.new("Attachment")

		attatchment.Parent = part
		force.Attachment0 = attatchment
		force.Parent = part
		part.Parent = gun

		part.Touched:Connect(function(hit)
			if canDamage == true then

				if hit ~= gun.Handle then
					canDamage = false
					part.Anchored = true
					part.CanCollide = false
					debris:AddItem(part, 10)

					if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= gun.Parent then
						hit.Parent.Humanoid.Health -= 10
						part:Destroy()
					end
				end	
			end	

		end)

		applyDrop(part, force, gun)

	
end)

Any solutions to this will be much appreciated! :heart:

Have you checked if the projectile comes into contact with anything?

Oh, i just realized that the part was anchoring, thanks!

1 Like