Starter tutorial | How to spawn parts with ProximityPrompts

Hello! In this tutorial, you will learn:

  • how to get Roblox Studio
  • get familiar with the controls
  • about ProximityPrompts
  • some scripting
  • how to spawn a part at a specific location
  • how to clear all items in a specific folder

You don’t need any scripting knowledge in order to follow this tutorial.
So, let’s get started!

Step 1 - Download and log into Roblox Studio

Most people here may already have it installed, but I am adding this step just in case you haven’t. If you already installed Studio and have your game open right now, skip to Step 3.

Start by going to create.roblox.com, and on your left you will see a section that says Resources. Under there, click “Download Studio” and run the application.

If all goes well, you should have Studio installed onto your computer. When you launch it, log in with your credentials, and you will be on the Home screen.

Congratulations, you just installed Roblox Studio, and you can now start making your own games!

Step 2 - Create a game

Now that you have the necessary programs installed, let’s create probably your first game!

  1. If not open already, open up Studio. You most likely won’t need to log in again.
  2. Go to New and click on Baseplate or Flat Terrain.
How do I know which one is right for me?

If you want to add realistic-looking grass and terrain with the Terrain editor, I suggest you should go with Flat Terrain. Otherwise, choose Baseplate. Note that the template that you choose does not affect the tutorial in any way.

  1. Click File > Save To Roblox and follow the on-screen instructions to give a name and description to your game.

Now, when you need to close Studio for something, you can find your game via the My Games section on the Home screen.

Step 3 - Setting up

If this did not work for you or if there were any technical issues during the process, follow this tutorial. If you feel that you need more time to become familiar with the program, then follow this tutorial.

Alright, now that you have learned the basics, we can finally start preparing our game.

  1. Make sure that both the Explorer and Properties windows are open. If they are not, navigate to the View tab in the game and click Explorer and Properties to open them.
  2. In the Explorer, right click on Workspace and click Insert Object. Then, search for Folder. When it is inserted, right click it, then click Rename. Name your folder “CurrentlySpawnedParts” without quotes.
  3. Do the same thing above, except insert a Part into the Workspace and name it “PartSpawner” without quotes.
  4. Do the same thing above, except insert a ProximityPrompt into “PartSpawner”. Leave the name alone.
  5. In the Properties tab, make sure the ProximityPrompt is highlighted and then do the following:
  • In the ActionText property, you can name it something like “Click To Spawn”.
  • In HoldDuration, if you want players to hold the prompt down to spawn a part, then set it to a value above 0. If you want players to simply click it, set it to 0.
  • To avoid any errors, leave RequiresLineOfSight unchecked.
  • KeyboardKeyCode is the key that players will have to hold down or press to spawn a part. Players on mobile can hold down their finger on the prompt. Console players will hold down the GamepadKeyCode button.
  • To avoid autoclickers, set ClickablePrompt to be unchecked.

Step 4 - Scripting the part spawner

We are now able to script our part spawner. First, insert a Script into the ProximityPrompt and name it anything you’d like. Next, double-click the script to open the Script Editor. Erase the “print(“Hello world!”)” line of code. Then, paste the following code into the script:

local prompt = script.Parent

prompt.Triggered:Connect(function()
	local spawnedPart = Instance.new('Part')
	spawnedPart.Name = "SpawnedPart"
	spawnedPart.Position = Vector3.new(0,1,0)
	spawnedPart.Parent = game.Workspace.CurrentlySpawnedParts
end)

The code explained: When the ProximityPrompt is triggered, we will spawn a part at 0,1,0 in the Workspace’s CurrentlySpawnedParts folder you just created.

Now test the game, and make sure it works!

Warning: Make sure that the script is not a LocalScript or a ModuleScript, otherwise it will NOT work.

Step 5 - Safety precautions

If a player spawns too many parts in your game, the game may crash! That’s not good, so we should make sure that the player can prevent that by adding our Clear Parts prompt.

  1. In the Workspace, insert a Part named ClearParts.
  2. In the ClearParts part, insert a ProximityPrompt and do the following in the Properties window:
  • In the ActionText, name it something like “Clear All Parts”.
  • In the HoldDuration property, I strongly recommend that you set it to a value above 0.
  • Make the KeyboardKeyCode a different key than the one you set for the SpawnParts prompt.
  • Set RequiresLineOfSight to false.
  1. Now, insert a Script into the ClearParts prompt, delete the code inside, and paste the following code:
local prompt = script.Parent

prompt.Triggered:Connect(function()
	local spawnedParts = game.Workspace.CurrentlySpawnedParts
	
	for _, part in pairs(spawnedParts:GetChildren()) do
		part:Destroy()
	end
end)

Explanation: When the ClearParts prompt is triggered, we will look for all the parts we have spawned. Then, we will loop through every single part and delete it until all of the parts spawned get deleted.

Now test your game, and make sure it works!

Warning: Make sure that the script is not a LocalScript or a ModuleScript, otherwise it will NOT work.

Step 6 - Finalizing changes and advanced options

We are almost there! To save our changes and make our game public:

  1. Go to File > Publish to Roblox to publish your game to the platform.
  2. Go to Game Settings > Permissions and set it to Friends for your friends to play, or Public for the world to see.

Congratulations! You just made a game! :partying_face:
Wait, don’t go yet! There are still some optional things you can do!

Optional items
  • In create.roblox.com, go to Creations > Experience > [your experience] and on the left, click Questionnaire. You should fill this out so more people can play your game.
  • Don’t stop here! Make a map for your game that players can walk around in!
  • Follow the part 2 tutorial that I may make (will put the link here if I make it)
  • Create an icon, thumbnail(s) and/or even a YouTube trailer for your game in Game Settings! These elements can go a long way.
  • Advertise your game!
  • Find a way to monetize your game!

Leave some feedback in the comments if you want to!

4 Likes

I just want to add that when triggering the ProximityPrompt, you can insert an already built object into the game instead of creating a part when the ProximityPrompt is triggered.

You can add your pre-built object into ServerStorage, create a script, clone the part from ServerStorage, then parent it the the workspace:

local serverStorage = game:GetService("ServerStorage")

local prompt = script.Parent

prompt.Triggered:Connect(function()
	local part = serverStorage.Part:Clone()
	part.Name = "SpawnedPart"
	part.Position = Vector3.new(0,1,0)
	part.Parent = workspace
end)
1 Like

Wait, what is this ‘Game’ supposed to be about?

I think the post is teaching us how to insert parts to the workspace using ProximityPrompts and how to remove them from the workspace using another ProximityPrompt?

Thats just from what I can see in the coding examples displayed above since there is no explanation in this topic as to what the game is going to be about.

1 Like

It’s literally saying it in the title that is a basic Clicker Game, but anyways he’s gonna make a Part 2 so…

I am confused because it doesn’t say this is part one so I have no clue if there will be a part two. I am also confused with the topic name of the post since the only thing we are clicking is the ProximityPrompts to spawn in objects.

Where where he says it @AustnBlox

1 Like

Ah ok. I missed that part. Thanks for letting me know.

But the part two isn’t made yet as of now so there is no guarantee of it happening even though he said it will things can sometimes happen or go wrong.

Yeah I know, he may also forget about it (even though that’s improbable as we are filling his Notification tab right now :rofl::rofl::rofl:)

2 Likes

Just clearing up some confusion:

This is just a basic start-up example for beginners with Studio that I made just because I was bored and wanted to help the community. Part 1 (this article) just deals with some basics. The fate of Part 2 is undecided, but it may add stuff like a leaderboard and monetization if the viewer may be interested. I don’t know. I just felt that this is a complete jump-start tutorial, and that Part 2 would be completely optional and not required to complete this whole tutorial.

Okay, now it’s clearer, you should change the title, as it’s misleading
Edit: noticed you edited the title, thanks

1 Like