Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I make an action happen when someone steps on a brick?

Hi guys, so I have an idea for a game. I need to have something that will perform an action, like load a map when it is stepped on. I am a very novice user when it comes to scripting, and I literally just begun to script. I don't plan to finish this game anytime soon, I expect for it to take a few months. Also, would anyone share how they learned LUA? They don't teach LUA at sites or anything, because it isn't used as much as other languages and isn't as complex. I'm getting one of the LUA books soon, but knowing how other people learned would be of much help.

1 answer

✓ Accepted answer

Well, this is how you would have something happen when you touch a brick. Put this script inside the brick.

--this is called when the brick is touched.  'part' is the object that touched the brick
script.Parent.Touched:connect(function(part) 
	--If you want to check if it was a player that touched the brick, you can do this: it will exit the function if no humanoid is found
	if not part.Parent:FindFirstChild("Humanoid") then return end
	--now we have learned that the part that touched the brick is a character, now we can continue with the function
	--(do stuff)
end)

As for learning Lua, check out the Roblox wiki and the wiki cookbook. They help a lot. You can also look at free model scripts to learn from them.

This discussion is preserved as it was. New answers, comments, and votes are closed.