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

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

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.

2 comments

0

bullet.Size = Vector3.new(range,0.52,0.52)

0

it didn't worked, the error is gone but the bullet isn't appearing

1 answer

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.

1 comment

0

Also thank you Denny9876 for helpping fix the error

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