The error is on line 29, trying to set the name so in another script it can tell if the part touched anything. I am purposely doing this on the client side. If there is anyway I can do this inside this script keeping it on the client, let me know. Here is my local script, inside a tool:

local gun = script.Parent
local ammo = game.ReplicatedStorage.NormalGunAmmo
local ActiveBullets = game.Workspace.ActiveBullets

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local debounce = false
local count = 0

local function number()
	for i,v in pairs(ActiveBullets:GetChildren())do
		count = count+1
	end
	return count
end

gun.Activated:Connect(function()
	if debounce == false then
		debounce = true
		local bullet = ammo:Clone()
		bullet.CFrame = gun.Handle.CFrame
		
		local BodyVelocity = Instance.new("BodyVelocity",bullet)
		BodyVelocity.P = Vector3.new(10000,10000,10000)
		BodyVelocity.Velocity = mouse.Hit.LookVector * 100
		
		bullet.Parent = ActiveBullets
		bullet.Name = "Bullet"..number
		wait(.75)
		debounce = false
	end
end)

Error is in the title, and again, it occurs on line 29 trying to set the name, thanks!

4 comments

0

Plus, you should declare another variable, since the script can get confused.

0

plus?

0

Replace line 29 with bullet.Name = "Bullet"..number()

0

thanks!