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

How do I get this part to clone in the exact same place?

Asked by 3 years ago

So I have this part that falls when you touch it, for an obby. But I want it to clone in the exact same place after 3 seconds so if you die you can do it again. What do I do? code:

script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")then script.Parent.Anchored = false end end)

wait(3)

also btw my powers about to go off so.. But I will respond after it comes back on.

1 answer

Log in to vote
0
Answered by 3 years ago
local part = script.Parent --your part, i just made a variable for it
local origPos = part.Position --we're just saving your part's position for later use

local debounce = false --i also added debounce

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and not debounce then
        local clonedPart = part:Clone() --clones our part

        debounce = true

        part.Anchored = false

        wait(3)

        clonedPart.Parent = workspace --parents the clone to workspace
        clonedPart.Position = origPos --position the clone to the position of your original part
        part = clonedPart --sets the clone part as the *part* so touched event can trigger from it (not really sure about this one tbh)

        debounce = false
    end
end)

Hoping you learned something! <3

0
thx a_crazyjester 21 — 3y
0
it didnt work .-. a_crazyjester 21 — 3y
Ad

Answer this question