It's for a sentry gun, whenever the player is in range, it spawns ball-shaped bullets, hurtling them at you. Here is the sentry gun script:

local part = script.Parent
local damage = 10
local range = 100
player = game.Players:GetPlayers()

        for i,v in pairs (player) do
		while (player.Character.Torso.Position - part.Position).magnitude <= range do
		local bullet = Instance.new("Part", game.Workspace)
		bullet.Name = "Bullet"
		bullet.Shape = "Ball"
		bullet.FormFactor = "Custom"
		bullet.Size = Vector3.new(0.2,0.2,0.2)
		bullet.Transparency = 0
		bullet.TopSurface = "Smooth"
		bullet.BottomSurface = "Smooth"
		bullet.BrickColor = BrickColor.new("Medium stone grey")
		bullet.CanCollide = false
		bullet.CFrame = part.CFrame
		bullet.CFrame = CFrame.new(bullet.Position, player.Torso.Position)
		local v = Instance.new("BodyVelocity", bullet)
		v.velocity = bullet.CFrame.lookVector * 90
		v.maxForce = Vector3.new(1,1,1) * math.huge
		part.Fire:Play()
		game.Debris:AddItem(bullet, 2)
		wait(0.5)
		end
		end

2 comments

0

I suspect the error is at line 7

0

What's it doing? What should it be doing instead? What do you know works? What doesn't work?