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

How do I make a part make a player take damage while an animation is playing?

Here's my animation loader for it

local racketdmgpart = racket.DamagePart
local wack = script.RacketWack -- animation
local mouse = game.Players.LocalPlayer:GetMouse()
local wackloader = player.Humanoid:LoadAnimation(wack)
mouse.Button1Down:Connect(function()
	wackloader:Play()
end)

Wanna make it so that racketdmgpart part will take health away from them like a kill brick Would love any help, tell me if you need anymore information

1 comment

0

Not entirely sure what you're trying to do, but this open source module might help: https://devforum.roblox.com/t/raycast-hitbox-401-for-all-your-melee-needs/374482

1 answer

Use the Touched event in the damage part.

local racketdmgpart = racket.DamagePart
local wack = script.RacketWack -- animation
local mouse = game.Players.LocalPlayer:GetMouse()
local wackloader = player.Humanoid:WaitForChild("Animator"):LoadAnimation(wack)

local IsTakingDamage = false

mouse.Button1Down:Connect(function()
	if IsTakingDamage == false then
		repeat task.wait() until wackloader.Length > 0
		wackloader:Play()
		IsTakingDamage = true
		task.wait(wackloader.Length)
		wackloader:Stop()
		IsTakingDamage = false
	end
end)

racketdmgpart.Touched:Connect(function(otherPart)
	local otherCharacter = otherPart.Parent
	local otherPlayer = game.Players:GetPlayerFromCharacter(otherCharacter)

	if otherPart and otherCharacter and otherPlayer then
		local otherHumanoid = otherCharacter:FindFirstChildOfClass("Humanoid")
		
		if otherHumanoid then
			if IsTakingDamage == true then
				otherHumanoid:TakeDamage(otherHumanoid.MaxHealth)
			end
		end
	end
end)

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