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

Im trying to make a gun to my game, but then i started getting this error : (error down there)?

Asked by 5 years ago

the error is here cuz it wouldn't fit up there XD error : Players.mewant_taco.Backpack.Pistola.CódigoPrincipal:18: bad argument #3 to 'Size' (Vector3 expected, got number)

this is the code i made (some of the thing are in portuguese XD)

local pistola = script.Parent
-- Lista de Valores --
local ammo = 12
local maxAmmo = 64
local damage = 20
local headshotDamage = 50
local range = 100
local coolDown = 1.5

-- Som de Disparar --
pistola.Activated:Connect(function()
    pistola.Handle.Disparo:Play()
end)

--Dsiparar a bala--
pistola.Activated:Connect(function()
    local bullet = Instance.new("Part")
    bullet.Size = range,0.52,0.52
    bullet.Position = game.StarterPack.Pistola.Hole.Position
end)

Pls help me solving this thing.

0
bullet.Size = Vector3.new(range,0.52,0.52) User#20279 0 — 5y
0
it didn't worked, the error is gone but the bullet isn't appearing mewant_taco 17 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Ok so, Denny9876 said i need to use a Vector3 and that's what i did, and the error is gone, but now the bullet wont appear. Here's the new 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 help me fixing this.

0
Also thank you Denny9876 for helpping fix the error mewant_taco 17 — 5y
Ad

Answer this question