Back to Library
Physics
Nov 22, 2025
Click to Jump
T
by terrorsoul
When a player clicks on another player thats in a vehicle, the target players vehicle will be forced to jump.
LUA
function SetupMouseInput(player)
-- Register a callback that fires when the player clicks
-- It passes the World Position of the click to "OnClickJump"
tm.playerUI.RegisterMouseDownPositionCallback(player.playerId, OnClickJump)
end
function OnClickJump(clickData)
local playerId = clickData.playerId
local targetPos = tm.vector3.Create(clickData.value)
-- Apply force to nearby players
local radius = 20
local jumpForce = 10000
local players = tm.players.CurrentPlayers()
for _, p in pairs(players) do
local struct = tm.players.OccupiedStructure(p.playerId)
if struct ~= nil then
local sPos = struct.GetPosition()
if tm.vector3.Distance(targetPos, sPos) < radius then
struct.AddForce(0, jumpForce, 0) -- Jumps them upwards
end
end
end
end
tm.players.OnPlayerJoined.add(SetupMouseInput)