What this is supposed to do is whenever the player is near, it fires bullets at it. Here is the script:
local part = script.Parent
local player = game.Players.LocalPlayer
local damage = 10
local mouse = player:GetMouse()
local range = 100
function Range ()
local mag = (part.CFrame.p - player.Character.Torso.CFrame.p).magnitude
part.Parent.Rotation = player.Character.Torso.Position
if mag >= range then
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.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.Character.Torso.p)
local v = Instance.new("BodyVelocity", bullet)
v.Velocity = bullet.CFrame.lookVector * 90
v.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
end
end
Range()

1 comment
Line 24 can be shorter: v.MaxForce = Vector3.new(1,1,1)*math.huge