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

Getting character from humanoid stored in this way?

Asked by
Azuc 112
5 years ago
Edited 5 years ago

So the monster NPC I am using stores the currently targeted humanoid in a objectvalue called "CurrentTargetHumanoid"

This value is set via this section of code:

    if closestCharacter ~= nil then
        Mind.CurrentTargetHumanoid.Value = closestCharacter.Humanoid
    end
end

It attacks with the following lines:

function Monster:Attack()
    local myPos, targetPos = Monster:GetCFrame().p, Monster:GetTargetCFrame().p

    if (myPos - targetPos).magnitude <= Settings.AttackRange.Value then
        Mind.CurrentTargetHumanoid.Value:TakeDamage(Settings.AttackDamage.Value)
        Data.LastAttack = tick()
        Data.AttackTrack:Play()
    end
end

I've been trying to figure out how to edit this in the following way, I want the character it attacks to be set to completely transparent and have new particle effects added to all body parts, I can do most of that myself I just dont know how to find the character it is attacking from how it has its humanoid stored.

0
Can you describe your problem more? User#19524 175 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

I think you'd do this..

function Monster:Attack()
    local myPos, targetPos = Monster:GetCFrame().p, Monster:GetTargetCFrame().p

    if (myPos - targetPos).magnitude <= Settings.AttackRange.Value then
        while (myPos - targetPos).magnitude <= Settings.AttackRange.Value do        
            Mind.CurrentTargetHumanoid.Value:TakeDamage(Settings.AttackDamage.Value)
            Data.LastAttack = tick()
            Data.AttackTrack:Play()
        end
    end
end
Ad

Answer this question