Back to Library
Physics Nov 23, 2025

Structure Turntable

T
by terrorsoul

Automatically rotates a player's vehicle slowly when within the radius of the center.

LUA
-- Configuration
local rotationSpeed = 0.5 
local showroomCenter = tm.vector3.Create(0, 300, 0)
local showroomRadius = 10

function UpdateShowroom()
    local players = tm.players.CurrentPlayers()
    
    for _, p in pairs(players) do
        -- Check if player is seated first
        if tm.players.IsPlayerInSeat(p.playerId) then
            local seatBlock = tm.players.GetPlayerSeatBlock(p.playerId)
            local structure = seatBlock.GetStructure()
            local pos = structure.GetPosition()
            
            -- Check distance
            if tm.vector3.Distance(pos, showroomCenter) < showroomRadius then
                -- Apply Torque to the SEAT block
                -- Y-axis torque spins it horizontally
                seatBlock.AddTorque(0, rotationSpeed * 1000, 0)
            end
        end
    end
end

function update()
    UpdateShowroom()
end

Discussion

Please log in to post a comment.