Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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

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 climethestair 1663 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

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)
Ad

Answer this question