When i go into studio and click, the local script gives this error attempt to perform arithmetic on local 'd' (a nil value) Anyone know why? Thanks

player = game.Players.LocalPlayer
character = game.Players.LocalPlayer.Character
gun = character:findFirstChild("Rifle")
flash = character.Flash
mouse = player:GetMouse()
reloading = false

function fire(d)
	print(d)
	reloading = true
	local bullet = Instance.new("Part",workspace)
	bullet.Size = Vector3.new(0.2,0.2,0.2)
	bullet.Transparency = 0
	bullet.Position = flash.Position+(d*5)
	bullet.Velocity = d*100
	local force = Instance.new("BodyForce",bullet)
	force.force = Vector3.new(0,3,0)
	
	reloading = false
end

mouse.Button1Down:connect(function()
if not reloading then
	fire()
end
end)

1 comment

0

What is "d" supposed to be? It isn't passed when you called the function in the Button1Down event.