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

Gun is no more shooting help?

Asked by 10 years ago

Well so the (FlameThrower) is no longer shooting once i added the onHit local stuff. I am trying to make the bullet (HotAir) to where when it hits a players humanoid it unanchores them if they are anchored.~~~~~~~~~~~~~~~~~ local debounce = false

function onHit(hit) local human = hit.Parent:findFirstChild("Humanoid") if (human ~= nil) and debounce == false then

            debounce = true

game.Workspace.FlameThrower.BlowDryer.HotAir.Anchored = false

            debounce = false
end

end

script.Parent.Touched:connect(onHit)

print("Flamethrower script loaded")

Tool = script.Parent

shooting = false reloadtime = 0

colors = {1, 208, 45, 11}

function fire(v,a)

local missile = Instance.new("Part")

local vCharacter = Tool.Parent

local head = vCharacter:findFirstChild("Head")
if head == nil then return end


local spawnPos = head.Position
spawnPos  = spawnPos + (v * 10)

missile.Name = "HotAir"

local dx = (math.random() - .5) * .01
local dy = (math.random() - .5) * .01
local dz = (math.random() - .5) * .01

missile.CFrame = CFrame.new(spawnPos, Vector3.new(dx,dy,dz))
missile.Size = Vector3.new(2,2,2)
missile.Velocity = v * 80
missile.BrickColor = BrickColor.new(colors[math.random(1, #colors)])
missile.Shape = 0
missile.CanCollide = false
missile.Transparency = 1--(math.random() * .5)

s = math.random(220,255) local fire = Instance.new("Fire") fire.Color = Color3.new((s/255),0,a) fire.SecondaryColor = Color3.new(s/400,0,a) fire.Parent = missile

local force = Instance.new("BodyForce")
force.force = Vector3.new(0,98 * 8,0)
force.Parent = missile

local new_script = script.Parent.Flame:clone()
new_script.Disabled = false
new_script.Parent = missile

missile.Parent = game.Workspace

end

Tool.Enabled = true function onActivated(mouse) if (Tool.Enabled == false) then return end Tool.Enabled = false if reloadtime > 0 then return end if shooting == true then return end print("start shooting") reloadtime = 1 shooting = true

local time = 0

local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
    print("Humanoid not found")
    return 
end

while shooting == true do
    local targetPos = humanoid.TargetPoint
    local lookAt = (targetPos - character.Head.Position).unit
    local dx = (math.random() - .5) * .1
    local dy = (math.random() - .5) * .1
    local dz = (math.random() - .5) * .1

    fire(Vector3.new(lookAt.x + dx, lookAt.y + dy, lookAt.z + dz),(time*5)/255)
    wait(.02)
    time = time + .02
    reloadtime = reloadtime + 0.02
    if time > 5.0 then shooting = false end
end


wait(reloadtime)
reloadtime = 0

Tool.Enabled = true

end

function onDeactivated(mouse) shooting = false end

script.Parent.Activated:connect(onActivated) script.Parent.Deactivated:connect(onDeactivated)

~~~~~~~~~~~~~~~~~

1 answer

Log in to vote
0
Answered by 10 years ago

A players parts will never be Anchored, so what you are doing is kind of pointless, just make it do damage.

Ad

Answer this question