how do i make a script when u touch part1, a new part2 pops up using instance.new
How do i make a script when u touch part1, a new part2 pops up using instance.new?
To make a script that creates a new part when you touch another part, you can use the Touched event on the part that you want to touch, and the Instance.new function to create a new instance of the Part class. Here is an example of how you could do this:
-- Define the name and size of the part that will be created local partName = "Part2" local partSize = Vector3.new(2, 2, 2) -- Define the part that you want to touch local part1 = script.Parent -- Bind a function to the Touched event on the part part1.Touched:Connect(function(otherPart) -- Check if the other part is a humanoid if otherPart:IsA("Humanoid") then -- Create a new part and set its properties local part2 = Instance.new("Part") part2.Name = partName part2.Size = partSize part2.Parent = workspace end end)
In this script, the Touched event is bound to a function that checks if the other part that was touched is a Humanoid. If it is, a new Part is created and added to the Workspace.
You can customize the script to change the name and size of the part that is created, as well as the part that you want to touch.