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

Why is my sword not doing damage when it's supposed too?

When you click it does play the animation, but it is supposed to deal damage as well.

Why isn't it? Am I not using the Touch Event correctly?

No errors btw

No errors btw
Player = game.Players.LocalPlayer

local tool = script.Parent

playing = true

tool.Equipped:connect(function(Mouse)

Mouse.Button1Down:connect(function()
	if playing then	
		playing = false
		print("Sword Hit")			
			local animaya = Instance.new("Animation")
				animaya.Parent = script.Parent
				animaya.AnimationId = "http://www.roblox.com/asset?id=476333585"   
             local animat = Player.Character.Humanoid.Animator:LoadAnimation(animaya)
				animat:Play()
			wait(1.4)
		playing = true
		end
	end)
end)
playing = true
function onTouched(hit)
	if playing then
		playing = false
	local hum = hit.Parent:findFirstChild("Humanoid")
		if (hum ~= nil) then
			hum.Health = hum.Health - 8
			wait(0.8)
			playing = true
		end	
	end	
end

game.StarterPack.Sword.Handle.Touched:connect(onTouched)

1 comment

0

You forgot to comment "No errors btw". That might be what causes your script to fail.

1 answer

you have 2 variables called playing and you are setting them seperately, try giving them different names?

1 comment

0

Wont work those are debounces.

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