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

Why does my sword do no damage sometimes?

This is the line of code i used and it's inside a server script

--//Variables
local tool = script.Parent
local player = tool.Parent.Parent
local char = player.Character
local hum = char:WaitForChild('Humanoid')

local debounce = false
--//Activated
tool.Activated:Connect(function()
	--//Animation
	local animation = Instance.new('Animation')
	animation.AnimationId = "rbxassetid://2690844038"
	local load = hum:LoadAnimation(animation)
	
	if not debounce then
	debounce = true
	load:Play()
	wait(0.5)
	debounce = false
	end
end)

local debounce2 = false
--//Touched
tool.Handle.Touched:Connect(function(hit)
	if debounce and hit and hit.Parent:FindFirstChild('Humanoid') and not debounce2 then
		debounce2 = true
		hit.Parent.Humanoid:TakeDamage(10)
		wait(0.5)
		debounce2 = false
	end
end)

Here's a gif that shows the problem. https://gyazo.com/c2df592e8e8bee75ab45651dc8772d60

3 comments

0

please try clicking slower and let me know if the issues continues

0

try replacing wait(0.5) with repeat wait() until not debounce on line 29 and does the animation last for exactly 0.5 seconds?

0

Yes it's exactly 0.5 and it didn't work sorry.

1 answer

If your sword is made by parts and is not a mesh then make a blade(transparent) on the swords blade

But it seems like your sword is a mesh

Try printing in the function when the handle is touched if it doesn't work then your probably are not hitting them.

Try doing it filtering enabled if you can.

1 comment

0

It prints sometimes and other times it doesn't just like how it was when it was dealing damage. Also the sword is already filtering enabled compatible since it's a server script inside the tool.

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