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

how do i make parts do damage and knockback?

Asked by 7 years ago
Edited 7 years ago

local Player = game.Players.LocalPlayer local User = Player.Character local Mouse = Player:GetMouse()

local function MercuryLightningMeteor()

local Projectile = Instance.new("Part",game.ServerStorage)

      Projectile.Shape = 0
      Projectile.Material = 288
      Projectile.Size = Vector3.new(50,50,50)
      Projectile.Anchored = true
      Projectile.CanCollide = false

local Particles = Instance.new("ParticleEmitter",Projectile)

      Particles.Texture = "rbxassetid://567502351"
      Particles.Rate = 40
      Particles.Lifetime = NumberRange.new(1)
      Particles.Rotation = NumberRange.new(1)
      Particles.RotSpeed = NumberRange.new(100,200)
      Particles.Size = NumberSequence.new(50)
      Particles.Speed = NumberRange.new(0)
      Particles.LockedToPart = true


local MoveSpeed = Instance.new("BodyVelocity",Projectile)

      MoveSpeed.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
      MoveSpeed.Velocity = Projectile.CFrame.lookVector*100

local ThunderClap = Instance.new("Sound",Projectile)

      ThunderClap.Looped = false
      ThunderClap.Volume = 10
      ThunderClap.MaxDistance = 10000
      ThunderClap.SoundId = "rbxassetid://357559831"

      User.Humanoid.JumpPower = 200
      User.Humanoid.Jump = true

      wait(1)

      User.UpperTorso.Anchored = true
      Projectile.Parent = workspace
      Projectile.CFrame = CFrame.new(User.UpperTorso.Position,Mouse.hit.p)
      Projectile.Position = User.UpperTorso.Position + Vector3.new(0,30,0)

      wait(0.5)

      Projectile.Anchored = false
      Projectile.CanCollide = true
      User.Humanoid.Jump = false
      ThunderClap.Playing = true

      wait(0.5)

      User.UpperTorso.Anchored = false

      wait(10)

      Projectile:Destroy()

end User.Humanoid.JumpPower = 50

      UIS = game:GetService("UserInputService")
      UIS.InputBegan:connect(function(Input)
      if UIS:GetFocusedTextBox() then return end
      if Input.UserInputType == Enum.UserInputType.Keyboard then
      if Input.KeyCode == Enum.KeyCode.Q then
      MercuryLightningMeteor()

end end end)

0
sorry for the code not being entirely printed on the code block no idea why it isn't SwordsDestinyGames -11 — 7y

1 answer

Log in to vote
0
Answered by
farrizbb 465 Moderation Voter
7 years ago

damage script

local debounce = true
Projectile.Touched:connect(function(hit)
    if debounce == true then
        debounce = false
        local x = hit.Parent:FindFirstChild("Humanoid")
           if x then
            x.Health = x.Health-10
            wait(0.7)
           end
        debounce = true
    end
end)

knock back simply give the the torso a bodyposition set it t the moving bullet and wait as long as you want then remove it

0
thanks SwordsDestinyGames -11 — 7y
Ad

Answer this question