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

Why is my part moving in somewhat random directions when I change only the Y?

Asked by
Warphi 51
4 years ago

Hi, I'm making an expandable shield script that is held on the players left hand. When trying to make it extend however, the outermost piece moves in a somewhat random direction relative to the innermost part of the shield.

remoteevent.OnServerEvent:Connect(function(player, hasgear)
    print(player, hasgear)
    if hasgear == false then
        local 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
        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)
rme2 = game.Workspace.Part.RemoteEvent2
rme2.OnServerEvent:Connect(function()
    for i = 0,.4,.04 do wait()
            weld2.C0 = weld2.C0 * CFrame.new(0,i,0)
    end
end)

Starting position

After being extended

It doesnt always extend in the same direction, but rarely goes straight up relative to the inner part. What am I doing wrong, how can I fix it?

1 answer

Log in to vote
1
Answered by 4 years ago

i solved this in the discord server, but basically instead of using a loop we are using a tween and instead weld2.C0 = weld2.C0 * CFrame.new(0,i,0) we did weld2.C0 += Vector3.new(0,1,0)

but then in the goal

Ad

Answer this question