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

How is Tool.Parent.parent equal to player and why is this guy using tables for debounce and combo?

Asked by 2 years ago
Edited 2 years ago
local Tool = script.Parent

local Player = Tool.Parent.Parent
local Char = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")

local Debounce = {}
local Combo = {}
local bvtable = {0,0,0,0,50}

Tool.Activated:Connect(function()
    if 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

    Combo[Player] += 1

    local Hit1 = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Hit1)
    local Hit2 = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Hit2)
    local Hit3 = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Hit3)
    local Hit4 = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Hit4)
    local Hit5 = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Hit5)

    local Eyes = Char.HumanoidRootPart.CFrame.LookVector
    local Distance = 4.5
    local GeneralWaitTIme = .4
    local OverallWait = 2.1

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

    local RayHitBox = workspace:Raycast((Char.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] then
                    local BV = Instance.new("BodyVelocity",RayHitBox.Instance.Parent:FindFirstChild("HumanoidRootPart")) 
                    BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
                    BV.Velocity = Char.HumanoidRootPart.CFrame.LookVector * bvtable[Combo[Player]]
                    RayHitBox.Instance.Parent.Humanoid:TakeDamage(5)
                    game.Debris:AddItem(BV,.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

    Debounce[Player] = nil
end)

btw this script is for a punch tool

1 answer

Log in to vote
0
Answered by 2 years ago

nvm player is just a new index thats being created its like putting Combo[1] its sending all that information to that index

Ad

Answer this question