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

Why does welding make me float in the air?

Asked by
Probix 80
8 years ago
Edited 8 years ago

I'm made a part that if touched, it would weld to the torso...but every time I touch it, it would cause me to float in the air and get stuck.

function WeldingTesting(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
        local torso = hit.Parent.Torso
        local weld = Instance.new("Weld")
        weld.Part0 = torso
        weld.C0 = torso.CFrame:inverse()
        weld.Part1 = script.Parent
        weld.C1 = script.Parent.CFrame:inverse()
        weld.Parent = script.Parent
        script.Parent.CFrame = torso.CFrame * CFrame.new(5,10,5)
        script.Parent.Anchored = false
        script.Parent.CanCollide = false
    end
end

script.Parent.Touched:connect(WeldingTesting)

Please help?

2 answers

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

EDIT:

I think I have figure it out. I have been experiencing the same problem with tools lying on the ground. When I weld them to my character, they weld him to the ground. Here is my fix:

Try cloning the part into the player, weld it, then delete the original part.

If that doesn't work, you will have to store the part inside a LocalScript inside the player or something, and weld it from there.

I'm not sure why this bug exists, but it does. Maybe because the part get's welded to the ground somehow? Maybe it's because when it get's welded, the part is somehow locked into position?


This is because:

1. The part is anchored.

2. ROBLOX welding gets glitchy with parts with CanCollide set to true (in some cases, anyway). Set CanCollide to false:

script.Parent.CanCollide = false

Hope I helped!

~TDP

0
Didn't work. I still float in the air. But, thanks for trying. Probix 80 — 8y
0
Edited. TheDeadlyPanther 2460 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

It's because achored is true, You basically welded yourself to a imobile part Turn anchored to false

script.parent.Anchored = false
0
Didn't work. I still float in the air. Probix 80 — 8y

Answer this question