I was making a gun to my game, and i made a code, but then i started getting an error. Then a guy named "Denny9876" told me to use a Vector3 to my code. And then the error was gone! But then, the code wasn't working, only the error was gone.
This is my code:
local pistola = script.Parent
local hole = game.StarterPack.Pistola.Hole
-- Lista de Valores --
local ammo = 12
local maxAmmo = 64
local damage = 20
local headshotDamage = 50
local range = 100
local coolDown = 1.5
-- impedir spamming --
local spam = false
-- Disparo --
pistola.Activated:Connect(function()
if spam == false then
spam = true
pistola.Handle.Disparo:Play()
local bullet = Instance.new("Part")
bullet.Size = Vector3.new(range,0.25,0.25)
bullet.CFrame = CFrame.new(hole.CFrame.Position)
bullet.Transparency = 0.5
bullet.CanCollide = false
spam = false
end
end)
Pls tell me what is wrong with my code, why isn't the bullet showing up, and how can i fix it?

2 comments
You didn't anchor the "bullet", thus it fell through the ground, also, the line "bullet.CFrame = CFrame.new(hole.CFrame.Position)" is unnecessary, you can just do bullet.CFrame =CFrame.new(hole.Position)
Thank you