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 7 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:

01game.Players.PlayerAdded:connect(function(player)
02    player.CharacterAdded:connect(function(character)
03local Armor  = script.Parent:Clone()
04Armor.Parent = character
05Armor.CFrame = character["Torso"].CFrame
06local Weld =  Instance.new("Weld" , character["Torso"])
07    Weld.Part1 = Armor
08    Weld.Part0 = character["Torso"]
09    end)
10end)

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
7 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:

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

Answer this question