Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My bullet fall, how to do it float?

Asked by 6 years ago

I want her float, her it that remains straight, how I make that?

Gyazo GIF

local mouse = game.Players.LocalPlayer:GetMouse()

--mouse.Move:connect(function()
--  print(mouse.Hit.x)
--end)

mouse.Button1Up:connect(function()
    if game.Players.LocalPlayer.Character.Humanoid.Health > 0 then
        local bullet = Instance.new("Part", workspace.Debris)
        bullet.FormFactor = "Custom"
        bullet.TopSurface = 0
        bullet.BottomSurface = 0
        bullet.Anchored = false
        bullet.CanCollide = false
        bullet.Size = Vector3.new(0.1, 0.1, 1.8)
        bullet.Material = 'Neon'
        bullet.BrickColor = BrickColor.new('Daisy orange')

        local BodyForce = Instance.new('BodyForce')
        BodyForce.Parent = bullet
        bullet.BodyForce.force = Vector3.new(mouse.Hit.p)

        bullet.Name = game.Players.LocalPlayer.Name
        if workspace:FindFirstChild('Debris') ~= nil then
            bullet.Parent = workspace.Debris
        else
            local DebrisFolder = Instance.new('Folder', workspace)
            DebrisFolder.Name = 'Debris'
            bullet.Parent = DebrisFolder
        end

        bullet.Velocity = (mouse.Hit.p-bullet.Position).unit*100
        bullet.CFrame = CFrame.new(game.Players.LocalPlayer.Character.AimPart.Position,mouse.Hit.p)
    end
end)
1
Also use the other force and experiment! User#18043 95 — 6y

1 answer

Log in to vote
2
Answered by
2eggnog 981 Moderation Voter
6 years ago
Edited 6 years ago

I believe what you're looking for is a BodyVelocity, not a BodyForce. A body velocity, assuming it has a high enough MaxForce, will keep the bullet moving straight in one direction.

bullet.CFrame = CFrame.new(game.Players.LocalPlayer.Character.AimPart.Position, mouse.Hit.p)
local BodyVelocity = Instance.new('BodyVelocity', bullet)
BodyVelocity.Velocity =  (mouse.Hit.p - bullet.Position).unit*10

However, if you insist on using a BodyForce, add the weight of the bullet to the Y axis of the force to counteract gravity, like this:

BodyForce.Force = Vector3.new(...) + Vector3.new(0, workspace.Gravity*bullet:GetMass(), 0)
0
Thank !:)) NiniBlackJackQc 1562 — 6y
1
Accept answer, m8.. Scared to give him points? httpOmqCxpcake 70 — 6y
Ad

Answer this question