Gravity Issue (BodyForce)

I am making some cards (uno cards tool) and I just seen this now

Script inside the card (ReplicatedStorage)

-----this is the card settings before being fired-----

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("ShootEvent")

local random = 1

RemoteEvent.OnServerEvent:Connect(function(player, gunPos, gunOr, mosPos)
	
	local card = ReplicatedStorage.Card:Clone()
	card.Parent = game.Workspace
	card.Position = gunPos
	if random == 1 then
		card.BrickColor = BrickColor.new("Bright blue")
		print(card.BrickColor)
		random = random + 1
	elseif random == 2 then
		card.BrickColor = BrickColor.new("Bright green")
		random = random + 1
		print(card.BrickColor)
	elseif random == 3 then
		card.BrickColor = BrickColor.new("Bright red")
		random = random + 1
		print(card.BrickColor)
	elseif random == 4 then
		card.BrickColor = BrickColor.new("Bright yellow")
		random = random - 3
		print(card.BrickColor)
	end
	
	local distance = (mosPos - gunPos).magnitude
	local speed = 200
	card.CFrame = CFrame.new(gunPos, mosPos)
	card.Velocity = card.CFrame.lookVector * speed	
	local fly = Instance.new("BodyForce",card)
	fly.Force = Vector3.new(0, card:GetMass() * workspace.Gravity, 0)
	card.Orientation = gunOr + Vector3.new(0, -180, 0)	
	local attacker = Instance.new("StringValue")
	attacker.Name = "Attacker"
	attacker.Parent = card
	attacker.Value = player.Name
end)

Any idea how I can fix this?

Can’t you just call Destroy() on the cards once they’ve touched the rig?

yes but that can be kinda broken the card can touch in “nothing” and simply destroy

This line in particular is causing the anti-gravity affect. The upwards force being applied to the cards is equal and opposite that of gravity. As far fixing this, it depends on what effect you’d like to create. I think it would look nice if the card dropped after hitting something. You could use .Touched to detect hits and then destroy the body force + change the card velocity to zero. As a side note, you can set the force to be slightly less than equal to gravity for arched projectile paths. Also, you could anchor / weld the cards on hit so they appear to “stick” in whatever they hit.

Regardless of what effect you want, it seems to me that you’ll need to detect hits and then change the card’s movement from there. Maybe also add a check that you’re hitting a particular NPC, model, etc. too if :Destroy is being called on nothing.

No what I mean is

Instance.Touched:Connect(function(touchingInstance)
    -- Run your code here
    touchingInstance:Destroy()
end)

So call Destroy() at the end of the function.

I mean if I remove that the card goes down (doesnt go straight )

Yes if you removed the whole thing it would drop quickly, but an unequal force like:
fly.Force = Vector3.new(0, 3/4*card:GetMass() * workspace.Gravity, 0)
should cause a slower drop for an arched path if you wanted that.

Setting the force and velocity to zero would be an alternative to Destroy as well. If .Touched is giving you false positives (detecting hits that don’t exist) you could try using raycasting.

I never used raycasting before but that got limit range?

Then check if the touch is from a character. You can destroy it when the damage is dealt.
I doubt you’d want to have tons of cards all over the place so you’d have to destroy them either way when they miss and hit something else.

No I only changed the card brickcolor

That helped but this still goes back.

If there is a limit then it should be large enough that it’s not a problem.

Ok I will try to use it. maybe that can fix my problem

You could try making a dropdown. (like bullet drop in fps)
Where the force applied goes down as the time goes on.

I will need one loop for that. I just want to make the card hit and drops without gravity

Raycasting does not have a limit as far as I know but longer rays take longer to compute. Ideally you should shoot a small ray repeatedly in front of the card in the direction it is moving. Nothing more than a few studs in length. Once the ray cast detects a hit, remove any velocity or force and the card should drop.

Disabling the force when it hits something is not an option?

Maybe I can destroy the bodyforce when the card hits something.

Nvm bad idea making :Destroy() is not good (on the card and bodyforce)

Just one thing is possible to remove the bodyForce when hits or just turn it off?