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

Getting character from humanoid stored in this way?

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.

1 comment

0

Can you describe your problem more?

1 answer

✓ Accepted answer

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

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