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

How can I clone a part only when a humanoid touches it?

Asked by 2 years ago
Edited 2 years ago
part = script.Parent
cloned = part:Clone()

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        cloned.Parent = game.Workspace

        end

        end
    end

end)
0
script looks fine, i believe theres just an extra end in there BulletproofVast 1033 — 2y
0
I suggest only cloning the part when the humanoid touches it not at the start of the script Neutron05 7 — 2y

2 answers

Log in to vote
0
Answered by
kiref81 -24
2 years ago
cloned = part:Clone()
Ad
Log in to vote
0
Answered by 2 years ago

Try this, you put 2 extra "ends" in your script

part = script.Parent
cloned = part:Clone()

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        cloned.Parent = game.Workspace

    end

end)

Answer this question