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

Why does this script that welds a player to the part only work once?

Asked by 5 years ago

i made a script that welds the hrp to a part when the part has been touched. it works, but if i delete the weld with the explorer, when i press the part nothing happends. why?

script:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local w = Instance.new("Weld")
        w.Part0 = script.Parent
        w.Part1 = hit.Parent.HumanoidRootPart
        w.C0 = script.Parent.CFrame:Inverse()
        w.C1 = hit.Parent.HumanoidRootPart.CFrame:Inverse()
        w.Parent = script.Parent
    end
end)

thx

Answer this question