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)
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.
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.
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.
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.