Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

0

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

1 answer

✓ Accepted answer

Use correct spelling. WalkSpeed not Walkspeed.

1 comment

0

OMG that literally fixed all the issues. I can't believe I missed that. Thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.