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 1 year ago
Edited 1 year 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 — 1y
0
I suggest only cloning the part when the humanoid touches it not at the start of the script Neutron05 7 — 1y

2 answers

Log in to vote
0
Answered by
kiref81 -24
1 year ago
cloned = part:Clone()
Ad
Log in to vote
0
Answered by 1 year 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