Attempt to call a number value

I’ve been working on my Gun System until I tried to finish up the visuals and for the smoke effect I was using the OTS Gun Systems code. And when I put it into my script it gave me the error “attempt to call a number value”

-- Error: Players.talkingpotato5000.PlayerScripts.Client:149: attempt to call a number value 

if material == Enum.Material.Brick or material == Enum.Material.Concrete or material == Enum.Material.Cobblestone or material == Enum.Material.SmoothPlastic then
								local mat = game.ReplicatedStorage.Assets.Impact.Concrete
								if mat then
									local hole = Instance.new("Part", workspace)
									local particles = mat:FindFirstChildWhichIsA("BasePart")
									local tab = mat.Sounds:GetChildren()
									local rs = tab[math.random(1, #tab)]
									local cl = rs:Clone()
									cl.Parent = hole
									cl:Play()
									if particles then
										for i,v in pairs(particles:GetChildren()) do
											if v:IsA("ParticleEmitter") then
												local c = v:Clone()
												c.Parent = hole
												delay(0.1, function()
													c.Enabled = false
												end)
											end
										end
									end
									hole.Size = Vector3.new(0.7, 0.7, 0.001)
									hole.Transparency = 1
									hole.CanCollide = false
									hole.Position = pos
									hole.CFrame = CFrame.new(pos,pos+normal)
									hole.Anchored = true
									local decal = mat:FindFirstChildOfClass("Decal")
									if decal then
										local clone = decal:Clone()
										clone.Parent = hole
									end
									game.Debris:AddItem(hole, 6)
								end
							end
							end
2 Likes

Which line is line 149?

s90a0s9f90asf7s0a

1 Like

This is the 149th line, I’m not sure where the error is

It doesn’t seem right that that is the line that would error. Can you please quickly run it again and see if it still says line 149? You may have modified some other lines in it so that that number is not the right one

Huh. Definitely odd. Can you try printing what c is? (If done in studio it will let you select the object by clicking the thing that shows in console)

c is a particle emitter, so when the gun is shot and hits a wall, it has its visuals (bullet holes etc)

Still can’t see any issue with the code. To be absolutely sure that that line is the issue, can you try commenting it out and seeing if the code runs without error (it will make the particle emitter stay on, but the code can be reenabled after the test)

image
It works but just shows endless particles until it’s cleared by debris

Huh, so it is definitely the line you said before… the one that has no numbers in it.

Probably a far shot, but does changing teh delay thing to something like this

spawn(function()
    wait(0.1)
    c.Enabled = false
end)

have any effect on it?

1 Like

Basically that error message means you are doing something like:

123()
1 Like

Honestly didn’t expect changing it to spawn() would have an effect on it, but apparently it did!