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

I have a barrage, but i dont know how to change the position?

Asked by 7 years ago

I have this code for a barrage attack, and everything goes well, but sometimes, the projectile spawns pushing me, i want him to stay a little bit ahead. What should i do?

player = game.Players.LocalPlayer
mouse = player:GetMouse()
Enabled = true


function onKeyDown(key)
 key = key:lower()
 if key == "g" then

  for i = 1,10 do
    wait(0.1)
    player.Character.Humanoid.WalkSpeed = 0
    local Random = math.random(-10,10)
    local Random2 = math.random(-4,10)
    wait(0.1)
    EarthBarrage = game.Workspace.EarthAttacks.EarthBarrage:Clone()
    EarthBarrage.Size = EarthBarrage.Size + Vector3.new(30,30,30)
    EarthBarrage.CFrame = player.Character["HumanoidRootPart"].CFrame * CFrame.new(Random,Random2,0)
    EarthBarrage.Parent = game.Workspace
    EarthBarrage.Anchored = false
    EBV = Instance.new("BodyVelocity")
    EBV.maxForce = Vector3.new(math.huge, math.huge, math.huge)
    EBV.Velocity = mouse.Hit.lookVector*70
    EBV.Parent = EarthBarrage



if i == 1 then
    game:GetService("Chat"):Chat(player.Character.Head, "Earth Barrage!")
end
if i == 10 then
    player.Character.Humanoid.WalkSpeed = 16
end

end


  local ten = true
  EarthBarrage.Touched:connect (function(hit)
    if not ten then return end
    ten = false
    local hum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
    if hum then
        hum:TakeDamage(0)
    end
    wait()
    ten = true
end)  

 end
 wait(1)
 Enabled = true
end

mouse.KeyDown:connect(onKeyDown)


Answer this question