Skip to content

Duel.GetFirstTarget ​

Signature ​

lua
Duel.GetFirstTarget() -> Card|nil

Description ​

Returns the first target card currently recorded for the resolving Chain. If multiple target cards were recorded, the remaining target cards are returned as additional values in recorded order. For effects that target several cards and affect only the remaining valid targets, Duel.GetTargetsRelateToChain is usually clearer.

How To Use It ​

Use this during resolution when the effect selected exactly one target card.

The binding returns all stored Chain targets as Lua return values; scripts commonly keep the first one when the effect selected exactly one card. Always check that the returned card still exists and is still related to the resolving effect before moving, destroying, equipping, or changing it:

lua
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) then
    Duel.SendtoHand(tc,nil,REASON_EFFECT)
end

For multiple targets, use Duel.GetTargetsRelateToChain() when you need the group of targets that are still related to the resolving Chain.

Returns ​

  • Card|nil - First recorded target card, followed by any additional target cards as extra Lua return values. No value is returned when the current Chain has no target cards.

Source ​

  • D:\Programs\GitHub\ygopro-core\libduel.cpp:4949

Guided Examples ​

Learn how to use this function in context:

Used By ​

Generated from the local Scripts/ folder and cards.cdb.

  • Detected in 4747 indexed script(s).
  • Search this function in the Script Explorer with Duel.GetFirstTarget.
CardIDScriptDetected Calls
Salamandra with Chain62091148Scripts/c62091148.lua1
Pendulum Evolution55795155Scripts/c55795155.lua1
Surprise Fusion35167375Scripts/c35167375.lua1
Ultra Polymerization76647978Scripts/c76647978.lua1
Goyo Emperor59255742Scripts/c59255742.lua1
Melffy Playtime Surprise58036097Scripts/c58036097.lua1
Fiendsmith's Sequence49867899Scripts/c49867899.lua1
El Shaddoll Apkallone50907446Scripts/c50907446.lua1
Mixousia the Confounder80843006Scripts/c80843006.lua1
Invoked Sorath43989315Scripts/c43989315.lua1
Performage Cup Tricker6812770Scripts/c6812770.lua2
Spirit Illusion71939275Scripts/c71939275.lua1
Ghostrick Renovation61818176Scripts/c61818176.lua2
Hecahands Tartaros57809669Scripts/c57809669.lua1
Enneacraft - Asta.PIXEA28454232Scripts/c28454232.lua1
Odd-Eyes Revolution Dragon16306932Scripts/c16306932.lua1
Resurgam Xyz49082032Scripts/c49082032.lua1
PSY-Framelord Omega74586817Scripts/c74586817.lua1
Teleport Fusion36494597Scripts/c36494597.lua1
Graydle Split75361204Scripts/c75361204.lua1
Enneacraft - Archa.TAIL81237046Scripts/c81237046.lua1
Shining Draw35906693Scripts/c35906693.lua2
Dark End Evaporation Dragon62002838Scripts/c62002838.lua1
Plunder Patroll Shipshape Ships Shipping44227727Scripts/c44227727.lua1
...and 4723 more

Script Examples ​

Salamandra with Chain (62091148) ​

Source: Scripts/c62091148.lua

lua
	local c=e:GetHandler()
	if not c:IsRelateToEffect(e) or c:IsStatus(STATUS_LEAVE_CONFIRMED) then return end
	local tc=Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) and tc:IsFaceup() and Duel.Equip(tp,c,tc) then
		local e1=Effect.CreateEffect(c)

Pendulum Evolution (55795155) ​

Source: Scripts/c55795155.lua

lua
end
function c55795155.atkop(e,tp,eg,ep,ev,re,r,rp)
	local tc=Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) then
		local e1=Effect.CreateEffect(e:GetHandler())

Surprise Fusion (35167375) ​

Source: Scripts/c35167375.lua

lua
	local c=e:GetHandler()
	local race,att=e:GetLabel()
	local ec=Duel.GetFirstTarget()
	if ec:IsRelateToChain() and ec:IsFaceup() and ec:IsType(TYPE_MONSTER) then
		local cres=ec:GetRace()~=race or ec:GetAttribute()~=att