ROBLOX TEXT

World Code

Tags:

Command

Creator:

durplesprunki_yt32457

Code:

function styTxt(l){let n=styTxt;if(n.e||(n.e={c:"color",w:"fontWeight",st:"fontStyle",s:"fontSize",o:"opacity"},n.t=/(\\\<)|<(st|[cworis]) *([^>]+)?>/g),l=="")return[""];const r=[],e=new Map;let t="",c=0;for(let{index:f,0:u,1:a,2:o,3:i}of[...l.matchAll(n.t),{index:l.length}]){if(t+=l.slice(c,f),c=f+(u?.length??0),a){t+="<";continue}if(t&&(r.push(e.size?{str:t,style:Object.fromEntries(e)}:t),t=""),f!=l.length)if(o=="r")e.clear();else if(o=="i"&&i){const s=Object.fromEntries(e);delete s.fontStyle,r.push({icon:i,style:s})}else{let s=n.e[o];i?e.set(s,o=="o"?Number(i):i):e.delete(s)}}return r}
let playerColors = {};  // Stores random colors for players
let chatTimers = {};  // Controls wait time before shrinking
let chatProgress = {};  // Tracks chat animation per player

// Assign random colors to players when they join
onPlayerJoin = (playerId) => {
    let randomColor = `#${Math.floor(Math.random() * 16777215).toString(16)}`;
    playerColors[playerId] = randomColor;  // Save player's color
};

// Tick function controls expansion, pause, and shrinking phases
tick = (dt) => {
    let playerIds = api.getPlayerIds();
    playerIds.forEach(playerId => {
        if (chatTimers[playerId]) {
            chatTimers[playerId] -= dt / 1000;  // Decrease timer in seconds
            if (chatTimers[playerId] <= 0) {
                chatProgress[playerId].isShrinking = true;  // Start shrinking phase
                chatTimers[playerId] = null;  // Remove wait timer

                // *Reset shrinking sequence correctly*
                let chatMessage = chatProgress[playerId].fullMessage;  // Get full message
                chatProgress[playerId].stages = [];  // Reset for shrinking phase
                for (let i = chatMessage.length; i >= 1; i--) {
                    chatProgress[playerId].stages.push(chatMessage.slice(0, i));  // Shrinking effect
                }
            }
        }

        if (chatProgress[playerId] && chatProgress[playerId].stages.length > 0) {
            let nextStage = chatProgress[playerId].stages.shift();  // Get next stage

            if (nextStage === "WAIT") return;  // Pause before shrinking

            api.setTargetedPlayerSettingForEveryone(playerId, "nameTagInfo", {
                backgroundColor: "#FFFFFF",
                content: styTxt(`<c black><w lighter>${nextStage}`),  
                subtitle: styTxt(`<w bold>${api.getEntityName(playerId)}`),
                subtitleBackgroundColor: "transparent"
            }, true);
        }

        // *Final Cleanup: Ensure it disappears completely*
        if (chatProgress[playerId] && chatProgress[playerId].isShrinking && chatProgress[playerId].stages.length === 0) {
            api.setTargetedPlayerSettingForEveryone(playerId, "nameTagInfo", {
                content: [],  // Clears chat bubble
                subtitle: styTxt(`<c white><w bold>${api.getEntityName(playerId)}`),
                subtitleBackgroundColor: "transparent"
            }, true);
            delete chatProgress[playerId];  // Remove animation tracking
        }
    });
};

// Handle chat message animation (Expands → Waits → Shrinks)
onPlayerChat = (playerId, chatMessage, channelName) => {
    chatTimers[playerId] = 5;  // Set timer for shrinking after 5 seconds
    let nameColor = playerColors[playerId] || "#FFFFFF";  // Assign random color
    chatProgress[playerId] = { fullMessage: chatMessage, stages: [], isShrinking: false };

    let mid = Math.floor(chatMessage.length / 2);

    // *Phase 1: Expand from middle outward*
    for (let i = 0; i <= mid; i++) {
        let left = chatMessage.slice(mid - i, mid);
        let right = chatMessage.slice(mid, mid + i + 1);
        chatProgress[playerId].stages.push(left + right);
    }

    // *Phase 2: Introduce 5-second delay before shrinking*
    chatTimers[playerId] = 5;  // Activate wait period
    chatProgress[playerId].stages.push("WAIT");

    // *Broadcast the message to the chat*
    let formattedMessage = [
        { str: `${api.getEntityName(playerId)}:`, style: { color: nameColor, fontWeight: "bold" } },
        { str: ` ${chatMessage}`, style: { color: "#FFFFFF" } }
    ];
    api.broadcastMessage(formattedMessage);  // Send formatted chat

    return null;  // Suppress default message
};

Instructions:

.