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

umm well making a combat system it works but doesnt do dmg?

Asked by 3 years ago
Edited 3 years ago

ok so code it shoud do dmg

try from line 41

local RS = game:GetService("ReplicatedStorage")
local Debounce = {}
local Combo = {}
local punch = RS:WaitForChild("Ok")
punch.OnServerEvent:Connect(function(Player)
    if Player.Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then return end

    if Debounce[Player] then return end
    Debounce[Player] = true

    if not Combo[Player] then Combo[Player] = 0 end

    local Character = Player.Character
    local Humanoid = Character.Humanoid

    Combo[Player] += 1

    local Hit1 = Humanoid:LoadAnimation(script.C1)
    local Hit2 = Humanoid:LoadAnimation(script.C2)
    local Hit3 = Humanoid:LoadAnimation(script.C3)
    local Hit4 = Humanoid:LoadAnimation(script.C4)
    local Hit5 = Humanoid:LoadAnimation(script.C5)

    local v1 = {}
    local Eyes = Character.HumanoidRootPart.CFrame.LookVector
    local Distance = 4.5
    local GeneralWaitTIme = .75
    local OverallWait = 2.1

    local RayCastPara = RaycastParams.new()
    RayCastPara.FilterDescendantsInstances = {Player.Character}
    RayCastPara.FilterType = Enum.RaycastFilterType.Blacklist

    local RayHitBox = workspace:Raycast((Character.HumanoidRootPart.CFrame).p, Eyes * Distance, RayCastPara)

    local function Speed()
        RayHitBox.Instance.Parent:FindFirstChild("Humanoid").WalkSpeed = 0
        RayHitBox.Instance.Parent:FindFirstChild("Humanoid").JumpPower = 0
    end

    local function Hitbox()
        if RayHitBox then
            if RayHitBox.Instance and RayHitBox.Instance.Parent:FindFirstChild("Humanoid") then
                if Combo[Player] == 5 then
                    local BV = Instance.new("BodyVelocity",RayHitBox.Instance.Parent:FindFirstChild("HumanoidRootPart")) 
                    BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
                    BV.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector * 40
                    RayHitBox.Instance.Parent.Humanoid:TakeDamage(5)
                    game.Debris:AddItem(BV,.5)
                    Speed()
                else
                    table.insert(v1, RayHitBox.Instance.Parent.Humanoid)
                    v1[1]:TakeDamage(5)
                    Speed()
                end
            end
        end
    end

    if Combo[Player] == 1 then
        Hit1:Play()
        Hitbox()
        wait(GeneralWaitTIme)
    end

    if Combo[Player] == 2 then
        Hit2:Play()
        Hitbox()
        wait(GeneralWaitTIme)
    end

    if Combo[Player] == 3 then
        Hit3:Play()
        Hitbox()
        wait(GeneralWaitTIme)
    end

    if Combo[Player] == 4 then
        Hit4:Play()
        Hitbox()
        wait(GeneralWaitTIme)
    end

    if Combo[Player] == 5 then
        Hit5:Play()
        Hitbox()
        wait(OverallWait)
        Combo[Player] = 0
    end


    delay(.4,function()
        if RayHitBox then
            if RayHitBox.Instance.Parent:FindFirstChild("Humanoid") and v1[1] == nil then
                if Combo[Player] then
                    print(Combo[Player])
                    RayHitBox.Instance.Parent:FindFirstChild("Humanoid").WalkSpeed = 16
                    RayHitBox.Instance.Parent:FindFirstChild("Humanoid").JumpPower = 50
                end
            end
        else
            print("Not Found")
        end
    end)    

    table.remove(v1, 1) 
    Debounce[Player] = nil
end)

help

Answer this question