I have a script that is supposed to weld a piece of metal plating to the players arm & it is supposed to rotate it depending on if it is welded to the right, bottom, front & so on.
But when I run the script it doesn't rotate it the full ninety degrees & it rotates it something more like 45 degrees.
Here is the code:
01 | _G.LimbPlatingWeldEnable = function (LR, FB, TB, Rot, Prt 0 , Prt 1 ) |
02 | if Prt 1 :FindFirstChild( "weld" ) = = nil then |
03 | Prt 1. CFrame = Prt 0. CFrame * CFrame.new(LR * 0.6 , TB * 0.6 , FB * - 0.6 ) * CFrame.Angles( LR * 0 , FB * 90 , TB * 90 ) |
04 | weld = Instance.new( "Weld" ) |
05 | weld.Part 0 = Prt 0 |
06 | weld.C 0 = Prt 0. CFrame:Inverse() |
07 | weld.Part 1 = Prt 1 |
08 | weld.C 1 = Prt 1. CFrame:Inverse() |
09 | weld.Parent = Prt 1 |
10 | weld.Parent.Anchored = false |
11 | weld.Parent.CanCollide = false |
12 | end |
13 | end |
LR is if the plate is to the left or right, 1 for right, -1 for left. FB is if the plate is to the front or back, 1 for front, -1 for back. TB is if the plate is on top or on the bottom, 1 for top, -1 for bottom. Prt0 is the players lower right arm. Prt1 is the metal plate.
You need to use math.rad
when handling angles like that. https://www.robloxdev.com/articles/Lua-Libraries/math#math.rad
So, you would do the following with the function:
01 | _G.LimbPlatingWeldEnable = function (LR, FB, TB, Rot, Prt 0 , Prt 1 ) |
02 | if Prt 1 :FindFirstChild( "weld" ) = = nil then |
03 | Prt 1. CFrame = Prt 0. CFrame * CFrame.new(LR * 0.6 , TB * 0.6 , FB * - 0.6 ) * CFrame.Angles( LR * 0 , math.rad(FB * 90 ), math.rad(TB * 90 )) |
04 | weld = Instance.new( "Weld" ) |
05 | weld.Part 0 = Prt 0 |
06 | weld.C 0 = Prt 0. CFrame:Inverse() |
07 | weld.Part 1 = Prt 1 |
08 | weld.C 1 = Prt 1. CFrame:Inverse() |
09 | weld.Parent = Prt 1 |
10 | weld.Parent.Anchored = false |
11 | weld.Parent.CanCollide = false |
12 | end |
13 | end |
Good luck! Accept my answer if it helped you out so I know, and leave me a comment if you don't understand something or still need help.