1. BrickPlanet Forum
  2. Game & Scripting Discussion
  3. Simple Lua script to create an object on button press
Simple Lua script to create an object on button press
jhon doe
Level 3
Joined Jul 16th 2025
Posts 1
Posted Jul 20th 2025 at 9:51PM
Hi everyone!
Here’s a simple Lua script that creates an object when a player presses a button:

lua

function onButtonPressed(player)
local ball = CreateObject("Ball", {x=0, y=5, z=0})
ball:ApplyForce(Vector3(0, 10, 0))
end

RegisterEvent("ButtonPressed", onButtonPressed)
Feel free to ask if you want me to explain how it works or if you need help modifying this script!
bps2
Level 11
Joined Feb 1st 2025
Posts 1,493
Posted Jul 21st 2025 at 5:16PM
Cool good job on helping the beginners :)

Search Forum

Thread Info

Replies
1
Views
7
Created Jul 20th 2025
Last Reply Jul 21st 2025