Back to Library
Spawning Nov 23, 2025

Melvin Shower

T
by terrorsoul

Spawns melvins above players in the sky at random intervals

LUA
local nextMelvinTime = 0

function UpdateMelvinShower()
    local time = tm.os.GetTime()
    
    if time > nextMelvinTime then
        nextMelvinTime = time + (math.random() * 3.0) -- Spawn a melvin between immediately and 3 seconds
        
        local players = tm.players.CurrentPlayers()
        for _, p in pairs(players) do
            local pPos = tm.players.GetPlayerTransform(p.playerId).GetPosition()
            
            -- Random Position in sky
            local x = pPos.x + math.random(-50, 50)
            local y = pPos.y + math.random(50, 120)
            local z = pPos.z + math.random(-50, 50)
            local spawnPos = tm.vector3.Create(x, y, z)
            
            -- Spawn Melvin
            local melvin = tm.physics.SpawnObject(spawnPos, "PFB_Birdo_Medium")
            
            -- Check if spawn was successful
            if melvin.Exists() then
                local transform = melvin.GetTransform()
                
                -- 1. Random Rotation
                -- Generate random angles for X, Y, Z axes
                local rx = math.random(0, 360)
                local ry = math.random(0, 360)
                local rz = math.random(0, 360)
                transform.SetRotation(rx, ry, rz)
                
                -- 2. Random Size
                local randomSize = 0.5 + (math.random() * 4.0)
                
                transform.SetScale(randomSize) 
            end
        end
    end
end

function update()
    UpdateMelvinShower()
end

Discussion

Please log in to post a comment.