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

Weld is rotating my armor piece?

Asked by 6 years ago

Hello, I have a script that duplicates a set of armor and welds it on the players' torso. It works, but the problem is that it's rotated. It's supposed to look like this, but instead it looks like this. Here is my script:

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
local Armor  = script.Parent:Clone()
Armor.Parent = character
Armor.CFrame = character["Torso"].CFrame
local Weld =  Instance.new("Weld" , character["Torso"])
    Weld.Part1 = Armor
    Weld.Part0 = character["Torso"]
    end)
end)

Just a quick question. Any help appreciated! Thanks!

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
6 years ago

It appears that the objects aren't aligned correctly with no relative offset rotation. Try running the code snippet that positions the Armor from command line to see if the armor is appearing rotated or not. If it isn't, I have no clue what's up, but if it is then you simply have to modify the Weld's C1 to accomodate:

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        local Armor  = script.Parent:Clone()
        Armor.Parent = character
        Armor.CFrame = character["Torso"].CFrame
        local Weld =  Instance.new("Weld" , character["Torso"])
            Weld.C1 = CFrame.Angle(0, math.pi/2, 0) --90* rotation about the y axis. Might need to be negative.
            Weld.Part1 = Armor
            Weld.Part0 = character["Torso"]
    end)
end)

Ad

Answer this question