Back to Library
Spawning
Nov 22, 2025
Spawn a barrel above player
T
by terrorsoul
Spawns a barrel above the player
LUA
function SpawnBarrelAbovePlayer(playerId)
-- Get the player's transform (position/rotation)
local playerTransform = tm.players.GetPlayerTransform(playerId)
-- Get current position from the transform
local currentPos = playerTransform.GetPosition()
-- Create a vector 5 units up
local offset = tm.vector3.Create(0, 5, 0)
-- Calculate spawn position by adding the offset
local spawnPos = tm.vector3.op_Addition(currentPos, offset)
-- Spawn the object (e.g., PFB_Barrel)
tm.physics.SpawnObject(spawnPos, "PFB_Barrel")
end