Time
"Time Wizard" + 1 Effect Monster
Once per turn, while you control this Fusion Summoned card: You can toss a coin and call it. Destroy as many monsters on the field as possible, and if you do, inflict damage equal to half the total original ATK of the destroyed face-up monsters. If you called the coin toss right, your opponent takes the damage, if you called it wrong, you take the damage.
local CARD_ID_0 = 71625222 --Time Wizard

local CARD_ID_0 = 71625222 --Time Wizard
local s, id, o = GetID()
function s.initial_effect(c)
	--fusion material
	c:EnableReviveLimit()
	aux.AddFusionProcCodeFun(c, CARD_ID_0, aux.FilterBoolFunction(Card.IsFusionType, TYPE_EFFECT), 1, true, true)
	--destroy
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetCategory(CATEGORY_COIN + CATEGORY_DESTROY + CATEGORY_DAMAGE)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1)
	e1:SetCondition(s.descon)
	e1:SetTarget(s.destg)
	e1:SetOperation(s.desop)
	c:RegisterEffect(e1)
	--fusion check
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
	e2:SetCondition(s.matcon)
	e2:SetOperation(s.matop)
	c:RegisterEffect(e2)
end
function s.matcon(e, tp, eg, ep, ev, re, r, rp)
	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
end
function s.matop(e, tp, eg, ep, ev, re, r, rp)
	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + 0xd6c0000, 0, 1)
end
function s.descon(e, tp, eg, ep, ev, re, r, rp)
	return e:GetHandler():GetFlagEffect(id) > 0
end
function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
	if chk == 0 then
		return g:GetCount() > 0
	end
	Duel.SetOperationInfo(0, CATEGORY_COIN, nil, 0, tp, 1)
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
end
function s.damfilter(c)
	if c:IsPreviousPosition(POS_FACEUP) then
		return math.max(c:GetTextAttack(), 0)
	else
		return 0
	end
end
function s.desop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
	if g:GetCount() > 0 then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_COIN)
		local coin = Duel.AnnounceCoin(tp)
		local res = Duel.TossCoin(tp, 1)
		local damp = 0
		if coin ~= res then
			damp = 1 - tp
		else
			damp = tp
		end
		if Duel.Destroy(g, REASON_EFFECT) ~= 0 then
			local og = Duel.GetOperatedGroup()
			local atk = math.ceil((og:GetSum(s.damfilter)) / 2)
			Duel.Damage(damp, atk, REASON_EFFECT)
		end
	end
end


Time
"Time Wizard" + 1 Effect Monster
Once per turn, while you control this Fusion Summoned card: You can toss a coin and call it. Destroy as many monsters on the field as possible, and if you do, inflict damage equal to half the total original ATK of the destroyed face-up monsters. If you called the coin toss right, your opponent takes the damage, if you called it wrong, you take the damage.
-- Time
local CARD_ID_0 = 71625222 --Time Wizard
local s, id, o = GetID()
function s.initial_effect(c)
	--fusion material
	c:EnableReviveLimit()
	aux.AddFusionProcCodeFun(c, CARD_ID_0, aux.FilterBoolFunction(Card.IsFusionType, TYPE_EFFECT), 1, true, true)
	--destroy
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetCategory(CATEGORY_COIN + CATEGORY_DESTROY + CATEGORY_DAMAGE)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1)
	e1:SetCondition(s.descon)
	e1:SetTarget(s.destg)
	e1:SetOperation(s.desop)
	c:RegisterEffect(e1)
	--fusion check
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
	e2:SetCondition(s.matcon)
	e2:SetOperation(s.matop)
	c:RegisterEffect(e2)
end
function s.matcon(e, tp, eg, ep, ev, re, r, rp)
	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
end
function s.matop(e, tp, eg, ep, ev, re, r, rp)
	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + 0xd6c0000, 0, 1)
end
function s.descon(e, tp, eg, ep, ev, re, r, rp)
	return e:GetHandler():GetFlagEffect(id) > 0
end
function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
	if chk == 0 then
		return g:GetCount() > 0
	end
	Duel.SetOperationInfo(0, CATEGORY_COIN, nil, 0, tp, 1)
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
end
function s.damfilter(c)
	if c:IsPreviousPosition(POS_FACEUP) then
		return math.max(c:GetTextAttack(), 0)
	else
		return 0
	end
end
function s.desop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
	if g:GetCount() > 0 then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_COIN)
		local coin = Duel.AnnounceCoin(tp)
		local res = Duel.TossCoin(tp, 1)
		local damp = 0
		if coin ~= res then
			damp = 1 - tp
		else
			damp = tp
		end
		if Duel.Destroy(g, REASON_EFFECT) ~= 0 then
			local og = Duel.GetOperatedGroup()
			local atk = math.ceil((og:GetSum(s.damfilter)) / 2)
			Duel.Damage(damp, atk, REASON_EFFECT)
		end
	end
end

