Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how do i make parts do damage and knockback?


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)

1 comment

0

sorry for the code not being entirely printed on the code block no idea why it isn't

1 answer

✓ Accepted answer

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

1 comment

0

thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.