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

Why does the character move away from the block?

Asked by 10 years ago

I made a script that's supposed to put you inside a part but when you touch it you are flung away a few studs before being welded. I think it might have to do with the cancollide being true but I want players to be able to push the brick around. Here's the script: debounce = true

function onTouch(h)
    if h.Parent:FindFirstChild("Humanoid") then
        h.Parent:MoveTo(script.Parent.Position)
        h.Parent.Torso.CFrame = script.Parent.CFrame
        local weld = Instance.new("Weld")
        weld.Parent = script.Parent
        weld.Part0 = h.Parent.Torso
        weld.C0 = h.Parent.Torso.CFrame:inverse()
        weld.Part1 = script.Parent
        weld.C1 = script.Parent.CFrame
        script.Parent.Anchored = false
    end
end

script.Parent.Touched:connect(onTouch)

1 answer

Log in to vote
0
Answered by 10 years ago

Maybe try the anchoring the torso before changing its position to the block and then unanchor it after welding it to the block.

0
kinda works but as soon as torso is unanchored it happens again purplescheer9 0 — 10y
Ad

Answer this question