Gravity Issue (BodyForce)

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?

You can make a tween which makes the force weaker by changing the force to 0,0,0 when it hits something

If I set to 0,0,0 the card will fly?

No that so when it hits something it doesn’t just fall down or fly away but should make it so the forces gets weaker and weaker until it doesn’t move anymore. (at which point you could despawn the card)

I can help you if you don’t know how to do a tween.

Also I want to know why just destroying the card or the body force isn’t ideal (so I understand more on what you want it to be like)?

I mean when you destroy the bodyForce the script can break (too many cards inside the workspace you will get some erros and the next cards not gonna have BodyForce)

Why wouldn’t it have a body force? The script doesn’t cut when another one is called but it finishes it current task of inserting the body force and changing the force. If you make the touch connection after the body force creation then there is no chance of it erroring since it has a body force. (ofc course you would need to disconnect the function when it’s touched something). If you mean you want to keep all the cards even after they’ve hit and dealth damage: It would be bad game design if you didn’t make a limit of dropped cards (basically everyone using them and the server lagging so bad because of unused cards. You can add a debris to the card so it destroys after the time you add to the argument)

I got cooldown on the cards. but I will try to change the BodyForce to 0,0,0

How does your current script look?

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

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

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
	card.Touched:Connect(function()
		fly.Force = Vector3.new(0, 0, 0)
	end)
end)
local touchConnection = card.Touched:Connect(function()
	fly.Force = Vector3.new(0, 0, 0)
    touchConnection:Disconnect()
end)

Change the touch to this so it disconnects it because it will no longer be in use after the force is already 0,0,0 (might have a typo)

image

I think I cant

local touchConnection maybe needs to be inside the function?

what does it say when you hover over the highlighted text?