Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

how do i make a script when u touch part1, a new part2 pops up using instance.new?

Asked by 1 year ago

how do i make a script when u touch part1, a new part2 pops up using instance.new

1 answer

Log in to vote
0
Answered by 1 year ago

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.

0
This will never get past the if statement. 'otherPart' will never be the Humanoid, because the Humanoid is not a part... xInfinityBear 1777 — 1y
0
When the character comes into contact with the given part, the returned part will be a body part of the character. The parent of that body part is the character model. From there you can check if the character has a Humanoid. xInfinityBear 1777 — 1y
Ad

Answer this question