Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Why isn't this working?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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
0
I suspect the error is at line 7 Noobegai -4 — 9y
0
What's it doing? What should it be doing instead? What do you know works? What doesn't work? BlueTaslem 18071 — 9y

Answer this question