So, I am working on a gun, and this one part of the gun will not work. I try to make the bullet fall with a body vector and it will not go down. It just floats up. Here's the script:




events.Fired.OnServerEvent:Connect(function(player)
	values.Ammo.Value = values.Ammo.Value - 1
	local c = player.Character
	local h = c:FindFirstChild("Humanoid")
	local m = player:GetMouse()
	local r = animations.Recoil
	local d = h:LoadAnimation(r)
	d:Play()
	local bullet = Instance.new("Part",game.Workspace.Bullets)
	bullet.Name = player.Name.." bullet"
	bullet.Size = Vector3.new(0.26,0.26,0.26)
	bullet.Shape = Enum.PartType.Ball
	bullet.TopSurface = Enum.SurfaceType.Smooth
	bullet.BottomSurface = Enum.SurfaceType.Smooth
	bullet.Position = script.Parent.Parent.ShootPart.Position
	bullet.BrickColor = BrickColor.new("Bright green")
	local bv = Instance.new("BodyVelocity",bullet)
	bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	bv.Velocity = m.Hit.lookVector*values.Speed.Value
	bullet.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 10
			wait(0.01)
			bullet:Destroy()
		end
	end)
	if values.Ammo.Value <= 0 and values.Clips >= 1 then
			values.Ammo.Value = 100
			values.Clips.Value = values.Clips.Value - 1
	end
end)


here's the error: 23:31:40.390 - Players.Ruflixx.Backpack.Gun.Scripts.Server:35: attempt to index local 'm' (a nil value)

2 comments

1

You forgot to add "local player = Game.Players.LocalPlayer" before m = player:GetMouse().

0

oh