New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
1

# Why does this shooting script have a bit offset from the goal?

Edited 3 months ago
local part = script.Parent
wait(2)
while wait(1) do
local Bullet = Instance.new("Part", workspace)
Bullet.Size = Vector3.new(1,1,1)
local BV = Instance.new("BodyVelocity", Bullet)
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
end


My bullet has a bit of offset and is not hitting me, it is shooting right beside my character. What is the problem?

1
gskw 590
3 months ago

It appears that you aren't setting the bullet's position where it should go. I assume script.Parent is a gun here. Thus you would want your bullet to start out at the position of your gun, but with this script the bullet actually starts out at the origin (0, 0, 0). After that, the bullet's velocity is calculated using a statement that seems to assume that the bullet starts out inside script.Parent; it creates a vector from the gun to BadAdmins' HumanoidRootPart. All in all, you want to assign the position to an appropriate value:

local part = script.Parent
wait(2)
while wait(1) do
local Bullet = Instance.new("Part", workspace)
Bullet.Size = Vector3.new(1,1,1)
Bullet.Position = part.Position -- Line added here
local BV = Instance.new("BodyVelocity", Bullet)
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
`