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

How can I move a part while still keeping it welded to the player?

Asked by
Warphi 51
3 years ago

Hi, sorry if the title is completely misleading, I’m really not sure how to word this problem. Basically, I’m creating a prototype extendable shield welded to the players left arm.

The shield model’s structure can be seen here: https://imgur.com/a/SdjieYq

as well as the in game view once welded: https://imgur.com/a/5UHguSV

What I am trying to create is a system where the outermost piece of the shield (marked with the sad face) extends upwards while still moving with the player as it walks around.

Here is weld to player script:

    print(player, hasgear)
    if hasgear == false then
        gear = shieldgroup:clone()
            gear.Handle.CFrame = workspace:WaitForChild(player.Name)["Left Arm"].CFrame * CFrame.new(-0.20616293, -0.415015221, -0.040222168, 1, 0, 0, 0, 0.999999881, 0, 0, 0, 1)
            gear.par2.CFrame = gear.Handle.CFrame * CFrame.new(0.539999008, 0.160001278, 0, 1, 0, 0, 0, -1, 0, 0, 0, -1)
            gear.Parent = player.Character
        local weld = Instance.new("Weld")
            weld.Part0 = gear.Handle
            weld.C0 = gear.Handle.CFrame:Inverse()
            weld.Part1 = game.Workspace[player.Name]["Left Arm"]
            weld.C1 = game.Workspace[player.Name]["Left Arm"].CFrame:Inverse()
            weld.Parent = gear.Handle
        local weld2 = Instance.new("Weld")
            weld2.Part0 = gear.par2
            weld2.C0 = gear.Handle.CFrame:Inverse()
            weld2.Part1 = gear.Handle
            weld2.C1 = gear.par2.CFrame:Inverse()
            weld2.Parent = gear.par2
    end
end)

My question is what system can I use to extend the outermost layer upwards relative to the inner most one while still having it move with the player. I have attempted to tween the part itself with tweenService, but that requires breaking the weld. I am unfamiliar with weld constraints but when I attempted to use them on this project, I did not understand how to properly offset the pieces from one another. Any and all help is appreciated.

0
you can move the weld cframe (C0 and C1) Leamir 3138 — 3y
0
wow im an idiot. i got 2 hours of sleep last night so ill just blame it on that. any chance you can post an actual answer so i can give u the credit? Warphi 51 — 3y

Answer this question