- BrickPlanet Forum
- Game & Scripting Discussion
- Simple Lua script to create an object on button press
Simple Lua script to create an object on button press
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!
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!
Posted Jul 21st 2025 at 5:16PM
Cool good job on helping the beginners :)
Search Forum
Thread Info
Replies
1
Views
7