Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My bullet fall, how to do it float?

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 comment

1

Also use the other force and experiment!

1 answer

✓ Accepted answer

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)

2 comments

0

Thank !:))

1

Accept answer, m8.. Scared to give him points?

This discussion is preserved as it was. New answers, comments, and votes are closed.