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

My Punch script is not making the player move away?[Does it sound like i'm competitive lol]

Asked by 4 years ago
Edited 4 years ago

So i created a punch script, when you activate the tool it fires an animation and deals damage and flings the opponent away.

It does not seem to fling anyone away?

SCRIPT:

local Tool = script.Parent;
local Animation = script.Animation
local Replicated = game:GetService("ReplicatedStorage")

local Debounce = false

wait(2)

local Humanoid = game.Players.LocalPlayer.Character.Humanoid

local CanAttack = true
local attacking = false
local equipped = false

Tool.Equipped:Connect(function()
    equipped = true
    RightArm = Humanoid.Parent:FindFirstChild("LeftHand")
    char = Tool.Parent
end)

Tool.Unequipped:Connect(function()
    equipped = false
    attacking = false
end)

Tool.Activated:Connect(function()
    if CanAttack and not Debounce then
        Debounce = true
        CanAttack = false
        attacking = true
    local AnimationTrack = Humanoid:LoadAnimation(Animation)
    AnimationTrack:Play()
    RightArm.Touched:Connect(function(hit)
        local hum = hit.Parent:FindFirstChild("Humanoid")
        if hum and hit.Parent ~= char and equipped and attacking then
            local BodyVelocity = Instance.new("BodyVelocity", hit.Parent.HumanoidRootPart)

            hum:TakeDamage(2)
            hum.Sit = true
            BodyVelocity.MaxForce = Vector3.new(5000, 5000, 5000)
            BodyVelocity.Velocity = (char:FindFirstChild("HumanoidRootPart").CFrame.lookVector*100)


            local Musics = game.Workspace.Music:GetChildren()

            local RandomMap = Musics[math.random(1, #Musics)]
            RandomMap:Play()
            print(RandomMap)
            end


            end)

                wait(1)
                CanAttack = true
                attacking = false

                wait(3)
                Debounce = false
                end
                end)

Answer this question