Help with Instance.new

Hello,

For the last few minutes, I have been trying to make a part that spams out blocks when you touch it. I have seen scripts that spam parts out when you touch them but you have to move around on it for the parts to spawn. I just want one that keeps going even when you’re staying still.

I apologize for the really messy script, I’m new.
image

Touched is a signal and Instance.new expects a string of the class you want to create. Here you’re using Touched as a conditional which is technically not illegal but it’s still incorrect use of a signal and you’re passing an object reference to Instance.new, so you’re using both incorrectly.

Did you mean to use clone or something? Not sure what you want to do specifically here. I understand the problem statement but not the intended outcome.

1 Like

I was hoping that parts would spawn at the said position when I touched a part I designated. with my humanoid. I apologize for the confusion, I am not a very good explainer.

In that case you’re on a decently good track. You can break your problem down:

  • Want to know when the player touches a certain area
  • Want to spawn blocks repeatedly for as long as the player is touching that part
  • Want to know when the player leaves that certain area

I’m not sure what the use of the second Instance is so that’s something you could get rid of, your loop will already handle spawning blocks with the given coordinates. The main part you’re going to want to resolve is how to meet the above list.

For me personally, I usually shoot a raycast down instead of using touched. I don’t really like touched and prefer to be able to check the player’s position relative to the area every frame. Wouldn’t call it an easier solution but from my perspective it’s how I like to do things.

3 Likes

Thanks for the help. I think I have a lot of the basics down, I’m just not sure why the part isn’t spawning at the position I put. I’m worried that I gave the computer all the details about the part, I just didn’t tell it to spawn the part when I touch it with my humanoid.