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

Why is my vest generating 90 degrees off?

Asked by 5 years ago
Edited 5 years ago

So, the script gives the player a team vest when they join. It does work, however. It faces it the wrong direction by 90 degrees.

I think the lines of code that are telling the weld the C0 and the C1 parts for both vests. I've already tried removing the lines, but it doesn't appear on my character after removing the lines.

https://i.gyazo.com/bcb355af8f6384c092d830d0aa019171.png

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        if plr.TeamColor == game:GetService("Teams"):FindFirstChild("Galactic Sharpshooters").TeamColor then
            local Vest = game.Lighting:FindFirstChild("Blue Vest"):Clone()
            Vest.Parent = char
            local V = Vest:GetChildren()

            for i = 1, #V do
                if V[i].className == "Part" or V[i].className == "UnionOperation" then
                    local W = Instance.new("Weld")
                    W.Part0 = Vest.Middle
                    W.Part1 = V[i]
                    local CJ = CFrame.new(Vest.Middle.Position)
                    local C0 = Vest.Middle.CFrame:inverse()*CJ
                    local C1 = V[i].CFrame:inverse()*CJ
                    W.C0 = C0
                    W.C1 = C1
                    W.Parent = Vest.Middle
                end

                local Y = Instance.new("Weld")

                Y.Part0 = char.Torso
                Y.Part1 = Vest.Middle
                Y.C0 = CFrame.new(0, 0, 0)
                Y.Parent = Y.Part0
            end

            local h = Vest:GetChildren()

            for i = 1, #h do
                if h[i].className == "Part" or h[i].className == "UnionOperation" then
                    h[i].Anchored = false
                    h[i].CanCollide = false
                end
            end
        else
            local Vest = game.ServerStorage:FindFirstChild("Green Vest"):Clone()
            Vest.Parent = char
            local V = Vest:GetChildren()

            for i = 1, #V do
                if V[i].className == "Part" or V[i].className == "UnionOperation" then
                    local W = Instance.new("Weld")
                    W.Part0 = Vest.Middle
                    W.Part1 = V[i]
                    local CJ = CFrame.new(Vest.Middle.Position)
                    local C0 = Vest.Middle.CFrame:inverse()*CJ
                    local C1 = V[i].CFrame:inverse()*CJ
                    W.C0 = C0
                    W.C1 = C1
                    W.Parent = Vest.Middle
                end

                local Y = Instance.new("Weld")

                Y.Part0 = char.Torso
                Y.Part1 = Vest.Middle
                Y.C0 = CFrame.new(0, 0, 0)
                Y.Parent = Y.Part0
            end

            local h = Vest:GetChildren()

            for i = 1, #h do
                if h[i].className == "Part" or h[i].className == "UnionOperation" then
                    h[i].Anchored = false
                    h[i].CanCollide = false
                end
            end
        end
    end)
end)
0
Tried adding a photo but gyazo being a mf grr LennonLight 95 — 5y
0
rotate the middle part with CFrame.Angles. - CFrame.Angles(math.rad(90), 0, 0) just play with it until it's the correct position hellmatic 1523 — 5y
0
Alright i'll try that LennonLight 95 — 5y
0
Where do I put it? LennonLight 95 — 5y

Answer this question