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

How to get this sword script working?

Asked by
Async_io 908 Moderation Voter
8 years ago

Okay, this is from a video that I watched by Stickmasterluke. It hasn't been working for me, and I copied every letter, space, and detail that he did. I need help with this. I know what the script does, I just don't know how to make one on my own. The issue is the activation. I'm trying to get the animations to play, which are in a different script, but it's deciding to not go like it's suppose to. I know it's the main script, not the animations. Anyways, the script.

tool = script.Parent
handle = tool:WaitForChild('Handle')
event = tool:WaitForChild('RemoteEvent')
swingtime = 1 
combowindow = 1
combo = 0
wait(1)



--speedboost = 1.25

handle.Touched:connect(function(hit)
    if equipped and humanoid and humanoid.Health > 0 and hit  and not hit:isDescendantOf(character) and hit.Parent.Enemy then
        local targethumanoid = hit.Parent:FindFirstChild('Humanoid')
        if targethumanoid and targethumanoid.Health > 0  and not hithumanoid[targethumanoid]then
            targethumanoid:TakeDamage(damage*combo)
            hithumanoid[targethumanoid] = true
        end
    end
end)

tool.Activated:connect(function()
lastclick = tick()
    local clickdelta = tick() - lastclick
    if clickdelta > swingtime then
    lastclick = tick()
    hithumanoid = {}
    if clickdelta < swingtime + combowindow then
        combo = (combo + 1) % 3
    else
        combo = 0
    end
    if player then
        if combo == 0 then
            event:FireClient(player, 'RunAnimation', 'Slash')
        elseif combo == 1     then
            event:FireClient(player, 'RunAnimation', 'Spin')
        elseif combo == 2   then
            event:FireClient(player, 'RunAnimation', 'Slam')
            end
        end
    end
end)

tool.Equipped:connect(function()
    tool.Parent:WaitForChild('Humanoid')
        character = tool.Parent
        player = game.Players:GetPlayerFromCharacter(character)
        damage = ((tool:WaitForChild('Config'):WaitForChild('Damage').Value * player.Stats.Ats.Strength.Value)/10) 
        combo = 0
        equipped = true
        humanoid = character:FindFirstChild('Humanoid')
            if humanoid then 
            --humanoid.Walkspeed = humanoid.Walkspeed*speedboost
            print ('Found Humanoid!')
        else
            character = nil 
            print ('There is no humanoid.')
        end
    end)

tool.Unequipped:connect(function()
    character =  nil
    equipped = false
    if humanoid then 
        --humanoid.Walkspeed = humanoid.Walkspeed/speedboost
        humanoid = nil
        print ('Unequipped')
    end
end)

Sorry for the ugliness, I'm trying to produce a bunch of scripts in order to hit a deadline.

Answer this question