How do I make Traps?
From Roblox Wiki
| Up one category: Tutorials |
Contents |
How do I make traps?
This tutorial shows how to make a rolling ball "trap" enclosure.
Fence
- Get 4 Bricks, and make them really long and of equal length
- Make the four bricks into a square wall.
Ball
- Click Workspace
- Insert > Object > Part
- Change the form of that newly inserted brick into the form: Ball.
- Click the brick/ball.
- Insert > Object > Script.
- Click the brick/ball.
- Insert > Object > BodyPosition.
- Make sure the surface of the ball is entirely smooth. (Top and bottom especially, otherwise the ball won't roll).
Scripting
-Double click on the script object. You'll see this.
print("Hello, World!")
-Delete that.. You don't need it.
-Now add this script:
local bp = script.Parent.BodyPosition
function onTouched(part)
h = part.Parent:findFirstChild("Humanoid")
if h ~= nil then
h.Health = h.Health - 5000
end
end
script.Parent.Touched:connect(onTouched)
while true do
bp.position = Vector3.new(math.random(-500,500), math.random(-500,500), math.random(-500,500))
wait(3)
end
- Place the ball inside of the fence.
- Test it.. It should roll around, and if you touch it, it kills you.
