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
When I hit an enemy, it kills them in one hit, instead of dealing only 20 damage.
The anchored and walk speed aren't working. The player can still move, not sure what to do about this. Thanks

1 comment
Quick edit: lines 18 and 22 are not commented out. Same issues.