--!strict -- Cosmetic components live on each client. Palettes are ordered armor, body, grip, and two channels. local Variants = {} type Colors = {cool: Color3, hot: Color3} type Animator = (now: number, flash: number) -> () type Switch = Beam | Trail | ParticleEmitter export type Effect = { root: Attachment, animate: Animator, switches: {Switch}, decorations: {Part}, } local function palette(hex: {string}): {Colors} local colors = {} for i = 1, #hex, 2 do table.insert(colors, {cool = Color3.fromHex(hex[i]), hot = Color3.fromHex(hex[i + 1])}) end return colors end Variants.palettes = { ThunderBlade = palette({"a06ce9", "e9dcff", "261b69", "5740c1", "26264c", "555377", "7745ff", "d3b1ff", "9956ff", "f8e5ff"}), CrimsonSeal = palette({"a24051", "ed8862", "560f28", "a02235", "411627", "762634", "ff492c", "ff9870", "e81a39", "ffd18a"}), Sakura = palette({"f5c8d6", "fff1ea", "98466f", "e88eaf", "6e385d", "a95884", "ff72b1", "ffe4f2", "b84387", "ffadcf"}), NeonGlitch = palette({"608b69", "a6eab4", "142b32", "315d52", "263842", "4c6459", "51ec27", "c4ff77", "13b587", "63ffd7"}), LunarOrbit = palette({"bd8841", "fbe6a6", "1d2955", "4b58a4", "282e4b", "56587c", "ffc15e", "fff3c9", "8574ff", "adc4ff"}), } local SPARK = "rbxasset://textures/particles/sparkles_main.dds" local PIXEL = "rbxasset://textures/particles/SquareParticle.png" local function pin(parent: Attachment): Attachment local point = Instance.new("Attachment") point.Parent = parent return point end local function line(a: Attachment, b: Attachment, color: Color3, width: number, alpha: number): Beam local beam = Instance.new("Beam") beam.Attachment0 = a beam.Attachment1 = b beam.FaceCamera = true beam.Segments = 1 beam.Width0 = width beam.Width1 = width beam.LightEmission = .98 beam.Color = ColorSequence.new(color) beam.Transparency = NumberSequence.new(alpha) beam.Enabled = false beam.Parent = a return beam end local function path(root: Attachment, count: number, closed: boolean, color: Color3, width: number, alpha: number): {Attachment} local points: {Attachment} = {} for i = 1, count do points[i] = pin(root) end for i = 1, (if closed then count else count - 1) do line(points[i], points[i % count + 1], color, width, alpha) end return points end local function specks(root: Attachment, color: Color3, texture: string, rate: number) local emitter = Instance.new("ParticleEmitter") emitter.Name = "SkinSpecks" emitter.Texture = texture emitter.Color = ColorSequence.new(Color3.fromRGB(255, 250, 248), color) emitter.LightEmission = .9 emitter.Size = NumberSequence.new(.10, .02) emitter.Transparency = NumberSequence.new(.16, 1) emitter.Rate = rate emitter.Lifetime = NumberRange.new(.24, .49) emitter.Speed = NumberRange.new(.48, 1.18) emitter.SpreadAngle = Vector2.new(48, 48) emitter.EmissionDirection = Enum.NormalId.Top emitter.Rotation = NumberRange.new(0, 360) emitter.LockedToPart = true emitter.Enabled = false emitter.Parent = root end local function shape(root: Attachment, name: string, size: Vector3, color: Color3, kind: Enum.PartType): Part local piece = Instance.new("Part") piece.Name = name piece.Shape = kind piece.Size = size piece.Color = color piece.Material = Enum.Material.Neon piece.Anchored = true piece.CanCollide = false piece.CanTouch = false piece.CanQuery = false piece.CastShadow = false piece.Transparency = 1 piece.Parent = root return piece end local function thunder(root: Attachment, _grip: BasePart): Animator local lilac = Color3.fromRGB(165, 102, 255) local white = Color3.fromRGB(240, 225, 255) local rng = Random.new() local bolts = {} for _, side in {-1, 1} do local bus = path(root, 8, false, white, .04, .08) for i = 1, #bus - 1 do line(bus[i], bus[i + 1], lilac, .125, .66) end table.insert(bolts, {side = side, bus = bus, branch = path(root, 4, false, lilac, .045, .24)}) end local sparks = pin(root) sparks.Position = Vector3.new(.05, .64, -1.8) specks(sparks, lilac, SPARK, 25) local nextArc = 0 return function(now, flash) if now < nextArc then return end nextArc = now + rng:NextNumber(.055, .092) for _, bolt in bolts do local start = -3.65 + rng:NextNumber(0, .55) for i, point in bolt.bus do local z = start + (i - 1) * .56 local jitter = rng:NextNumber(-.19, .19) * (1 + flash * .35) point.Position = Vector3.new(bolt.side * (.34 + rng:NextNumber(0, .072)), .47 + jitter, z) end local origin = bolt.bus[rng:NextInteger(3, 5)].Position for i, point in bolt.branch do local step = i - 1 point.Position = origin + Vector3.new(.036 * step * bolt.side, .13 * step, .21 * step) end end end end local function seal(root: Attachment, _grip: BasePart): Animator local gold = Color3.fromRGB(255, 181, 83) local red = Color3.fromRGB(255, 54, 47) local marks = {} for _, side in {-1, 1} do local center = Vector3.new(.38 * side, .49, -.74) local hex = path(root, 6, true, red, .060, .15) for i, node in hex do line(node, hex[i % #hex + 1], red, .16, .76) end table.insert(marks, {center = center, outer = hex, inner = path(root, 3, true, gold, .048, .08), side = side}) end local embers = pin(root) embers.Position = Vector3.new(0, .8, -.73) specks(embers, Color3.fromRGB(255, 93, 47), PIXEL, 17) return function(now, flash) for _, mark in marks do local radius = .34 + .041 * math.sin(now * 5.6) + .072 * flash for i, point in mark.outer do local theta = now * 1.75 * mark.side + (i - 1) * math.pi / 3 point.Position = mark.center + Vector3.new(0, math.cos(theta) * radius, math.sin(theta) * radius) end for i, point in mark.inner do local theta = -now * 1.34 * mark.side + (i - 1) * 2 * math.pi / 3 point.Position = mark.center + Vector3.new(.013 * mark.side, math.cos(theta) * radius * .67, math.sin(theta) * radius * .67) end end end end local function sakura(root: Attachment, grip: BasePart): Animator local pink = Color3.fromRGB(249, 82, 150) local pale = Color3.fromRGB(255, 208, 226) local petals: {Part} = {} for i = 1, 12 do local tint = pink:Lerp(pale, (i % 4) / 3) local petal = shape(root, "Petal", Vector3.new(.14, .14, .14), tint, Enum.PartType.Block) petal.Material = Enum.Material.SmoothPlastic local mesh = Instance.new("SpecialMesh") mesh.MeshType = Enum.MeshType.Sphere mesh.Scale = Vector3.new(1.12, .25, 1.9) mesh.Parent = petal table.insert(petals, petal) end local pollen = pin(root) pollen.Position = Vector3.new(0, .56, -2.4) specks(pollen, pink, SPARK, 18) return function(now, flash) local base = grip.CFrame for i, petal in petals do local u = (now * (.58 + (i % 3) * .076) + i * .134) % 1 local spin = now * 4.3 + i * 2.39 local spread = .24 + .36 * u + .05 * flash local at = Vector3.new(math.cos(spin) * spread, .47 + math.sin(spin) * spread * .66 + .25 * u, -3.4 + u * 4.42) petal.CFrame = base * CFrame.new(at) * CFrame.fromOrientation(spin * .9, spin * .37, spin * 1.33) petal.Transparency = 1 - .95 * math.sin(u * math.pi) ^ .49 end end end local function glitch(root: Attachment, grip: BasePart): Animator local mint = Color3.fromRGB(115, 255, 62) local sea = Color3.fromRGB(30, 245, 177) local scans: {Part} = {} local scanlines = {} for _, side in {-1, 1} do local a, b = pin(root), pin(root) line(a, b, mint, .021, .25) line(a, b, sea, .086, .72) table.insert(scanlines, {side = side, bottom = a, top = b}) end for i = 1, 14 do local color = if i % 3 == 0 then sea else mint table.insert(scans, shape(root, "GlitchPixel", Vector3.new(.028, .065, .19), color, Enum.PartType.Block)) end local bits = pin(root) bits.Position = Vector3.new(0, .67, -1.6) specks(bits, mint, PIXEL, 21) return function(now, flash) local base = grip.CFrame local tick = math.floor(now * 15) local sweep = (now * 1.05) % 1 for _, band in scanlines do local x = .35 * band.side local z = -3.35 + 4.08 * sweep band.bottom.Position = Vector3.new(x, .22, z) band.top.Position = Vector3.new(x, .84, z + .06) end for i, pixel in scans do local side = if i % 2 == 0 then -1 else 1 local offset = math.sin(tick * 7.8 + i * 18.8) local bank = (i - 1) % 7 local z = -3.82 + ((sweep + math.floor(bank / 3) * .34) % 1) * 4.9 + offset * .22 pixel.Size = Vector3.new(.028, .043 + .018 * bank, .13 + .20 * math.abs(offset) + .08 * flash) pixel.CFrame = base * CFrame.new(side * (.322 + bank * .015), .28 + bank * .103, z) pixel.Transparency = if (tick + i * 3) % 8 < 2 then 1 else .21 + math.abs(offset) * .3 end end end local function orbit(root: Attachment, grip: BasePart): Animator local gold = Color3.fromRGB(255, 218, 123) local violet = Color3.fromRGB(165, 169, 255) local stars: {Part} = {} for i = 1, 5 do local tint = if i % 2 == 0 then violet else gold local bead = shape(root, "OrbitStar", Vector3.new(.065, .065, .065), tint, Enum.PartType.Ball) table.insert(stars, bead) local a = Instance.new("Attachment") a.Position = Vector3.new(0, -.029, 0) a.Parent = bead local b = Instance.new("Attachment") b.Position = Vector3.new(0, .029, 0) b.Parent = bead local trail = Instance.new("Trail") trail.Attachment0 = a trail.Attachment1 = b trail.Color = ColorSequence.new(tint, Color3.fromRGB(93, 100, 248)) trail.Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, .15), NumberSequenceKeypoint.new(.5, .58), NumberSequenceKeypoint.new(1, 1), }) trail.WidthScale = NumberSequence.new(1, 0) trail.FaceCamera = true trail.LightEmission = .94 trail.Lifetime = .24 trail.MaxLength = .76 trail.Enabled = false trail.Parent = bead end local dust = pin(root) dust.Position = Vector3.new(.11, .67, -.69) specks(dust, gold, SPARK, 26) return function(now, flash) local base = grip.CFrame for i, star in stars do local theta = now * (5.1 + i * .18) + i * 2.39 local radius = .37 + .048 * i + .09 * flash local z = -1.15 - math.cos(theta * .51 + i) * 1.59 star.CFrame = base * CFrame.new(math.cos(theta) * radius, .46 + math.sin(theta) * radius, z) star.Transparency = .05 + .18 * (1 + math.sin(theta * 2)) end end end local builders: {[string]: (Attachment, BasePart) -> Animator} = { ThunderBlade = thunder, CrimsonSeal = seal, Sakura = sakura, NeonGlitch = glitch, LunarOrbit = orbit, } function Variants.create(id: string, grip: BasePart): Effect local root = Instance.new("Attachment") root.Name = "SkinFx_" .. id root.Parent = grip local animate = builders[id](root, grip) local switches: {Switch} = {} local decorations: {Part} = {} for _, instance in root:GetDescendants() do if instance:IsA("Beam") or instance:IsA("Trail") or instance:IsA("ParticleEmitter") then table.insert(switches, instance) elseif instance:IsA("Part") then table.insert(decorations, instance) end end return {root = root, animate = animate, switches = switches, decorations = decorations} end function Variants.setVisible(effect: Effect, visible: boolean) for _, switch in effect.switches do switch.Enabled = visible if not visible and (switch:IsA("ParticleEmitter") or switch:IsA("Trail")) then switch:Clear() end end if not visible then for _, decoration in effect.decorations do decoration.Transparency = 1 end end end return Variants