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

Why isn't my blow function working for my stun sword?

Asked by 6 years ago

My function (based off the generic link sword blow function) is part of a stun sword. I have two problems with it that I'm stumped on.

function blow(hit)
    if (hit.Parent == nil) then return end -- happens when bullet hits sword
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    local torso = hit.Parent:FindFirstChild("Torso")
    local vCharacter = script.Parent.Parent
    local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
    if humanoid ~= nil and hum ~= nil and HitDamageEnabled == true then
        -- final check, make sure sword is in-hand
    humanoid:TakeDamage(20)
    local hitani = Instance.new("Animation")
    hitani.AnimationId = "http://www.roblox.com/Asset?ID=1588878466"
    hitani.Parent = humanoid.Parent

    local hitTrack = humanoid:LoadAnimation(hitani)
    hitTrack:Play()
    humanoid.Walkspeed = 0
    torso.Anchored = true
    --HitDamageEnabled = false
    wait(1)
    torso.Anchored = false
    humanoid.Walkspeed = 16
    --HitDamageEnabled = true

    end
end
  1. When I hit an enemy, it kills them in one hit, instead of dealing only 20 damage.

  2. The anchored and walk speed aren't working. The player can still move, not sure what to do about this. Thanks

0
Quick edit: lines 18 and 22 are not commented out. Same issues. tygerupercut3 68 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Use correct spelling. WalkSpeed not Walkspeed.

0
OMG that literally fixed all the issues. I can't believe I missed that. Thank you so much! tygerupercut3 68 — 6y
Ad

Answer this question