Advertisement
AustinnK

Metalworks weldgui 2.0

Feb 21st, 2020
2,269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.96 KB | None | 0 0
  1. --by Austin K
  2. local coregui = game:GetService("CoreGui")
  3. local Remote = game.ReplicatedStorage.Remotes['ClientMakeWeldJoint']
  4. local localplayer = game.Players.LocalPlayer
  5. local Mouse = localplayer:GetMouse()
  6.  
  7. local w1
  8. local w2
  9. local ghost
  10. --ui
  11. local ScreenGui = Instance.new("ScreenGui")
  12. local Weld2 = Instance.new("TextLabel")
  13. local Weld1 = Instance.new("TextLabel")
  14. local TextButton = Instance.new("TextButton")
  15. local WeldRot = Instance.new("TextBox")
  16. local WeldPos = Instance.new("TextBox")
  17.  
  18. local square = Instance.new("BoxHandleAdornment", workspace)
  19. square.Size = Vector3.new(0.05, 0.05, 0.05)
  20. square.Color3 = BrickColor.new("Really red").Color
  21. square.ZIndex = 1
  22. square.AlwaysOnTop = true
  23. --Properties:
  24. ScreenGui.Parent = game:GetService("CoreGui")
  25. ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  26.  
  27. Weld2.Name = "Weld2"
  28. Weld2.Parent = ScreenGui
  29. Weld2.AnchorPoint = Vector2.new(0.5, 0.5)
  30. Weld2.BackgroundColor3 = Color3.new(1, 0.470588, 0)
  31. Weld2.BackgroundTransparency = 0.80000001192093
  32. Weld2.Position = UDim2.new(0.910000026, 0, 0.419999987, 0)
  33. Weld2.Size = UDim2.new(0.150000006, 0, 0.0500000007, 0)
  34. Weld2.Font = Enum.Font.SourceSansLight
  35. Weld2.Text = "Part1:"
  36. Weld2.TextColor3 = Color3.new(1, 1, 1)
  37. Weld2.TextSize = 30
  38.  
  39. Weld1.Name = "Weld1"
  40. Weld1.Parent = ScreenGui
  41. Weld1.AnchorPoint = Vector2.new(0.5, 0.5)
  42. Weld1.BackgroundColor3 = Color3.new(1, 0.470588, 0)
  43. Weld1.BackgroundTransparency = 0.80000001192093
  44. Weld1.Position = UDim2.new(0.910000026, 0, 0.360000014, 0)
  45. Weld1.Size = UDim2.new(0.150000006, 0, 0.0500000007, 0)
  46. Weld1.Font = Enum.Font.SourceSansLight
  47. Weld1.Text = "Part0:"
  48. Weld1.TextColor3 = Color3.new(1, 1, 1)
  49. Weld1.TextSize = 30
  50.  
  51. TextButton.Parent = ScreenGui
  52. TextButton.AnchorPoint = Vector2.new(0.5, 0.5)
  53. TextButton.BackgroundColor3 = Color3.new(1, 0.470588, 0)
  54. TextButton.BackgroundTransparency = 0.80000001192093
  55. TextButton.BorderColor3 = Color3.new(0, 0, 0)
  56. TextButton.BorderSizePixel = 2
  57. TextButton.Position = UDim2.new(0.910000026, 0, 0.644999981, 0)
  58. TextButton.Size = UDim2.new(0.100000001, 0, 0.0500000007, 0)
  59. TextButton.Font = Enum.Font.SourceSansLight
  60. TextButton.Text = "Weld"
  61. TextButton.TextColor3 = Color3.new(1, 1, 1)
  62. TextButton.TextSize = 30
  63. TextButton.TextWrapped = true
  64.  
  65. WeldRot.Name = "WeldRot"
  66. WeldRot.Parent = ScreenGui
  67. WeldRot.AnchorPoint = Vector2.new(0.5, 0.5)
  68. WeldRot.BackgroundColor3 = Color3.new(1, 0.470588, 0)
  69. WeldRot.BackgroundTransparency = 0.80000001192093
  70. WeldRot.BorderColor3 = Color3.new(1, 1, 1)
  71. WeldRot.BorderSizePixel = 2
  72. WeldRot.Position = UDim2.new(0.910000026, 0, 0.579999983, 0)
  73. WeldRot.Size = UDim2.new(0.150000006, 0, 0.0500000007, 0)
  74. WeldRot.ClearTextOnFocus = false
  75. WeldRot.Font = Enum.Font.SourceSansLight
  76. WeldRot.PlaceholderText = "Rotation"
  77. WeldRot.Text = "0,0,0"
  78. WeldRot.TextColor3 = Color3.new(1, 1, 1)
  79. WeldRot.TextScaled = true
  80. WeldRot.TextSize = 30
  81. WeldRot.TextWrapped = true
  82.  
  83. WeldPos.Name = "WeldPos"
  84. WeldPos.Parent = ScreenGui
  85. WeldPos.AnchorPoint = Vector2.new(0.5, 0.5)
  86. WeldPos.BackgroundColor3 = Color3.new(1, 0.470588, 0)
  87. WeldPos.BackgroundTransparency = 0.80000001192093
  88. WeldPos.BorderColor3 = Color3.new(1, 1, 1)
  89. WeldPos.BorderSizePixel = 2
  90. WeldPos.Position = UDim2.new(0.910000026, 0, 0.5, 0)
  91. WeldPos.Size = UDim2.new(0.150000006, 0, 0.0799999982, 0)
  92. WeldPos.ClearTextOnFocus = false
  93. WeldPos.Font = Enum.Font.SourceSansLight
  94. WeldPos.PlaceholderText = "X,Y,Z"
  95. WeldPos.Text = "0,0,0"
  96. WeldPos.TextColor3 = Color3.new(1, 1, 1)
  97. WeldPos.TextScaled = true
  98. WeldPos.TextSize = 30
  99. WeldPos.TextWrapped = true
  100.  
  101.  
  102. --extra functions
  103. function EasyRound(Number, Increment)
  104. if Increment == 0 then Increment = 0.001; end
  105. local MultipleDifference = Number % Increment;
  106. local LowerMultiple = Number - MultipleDifference;
  107. local UpperMultiple = Number - MultipleDifference + Increment;
  108. local LowerMultipleProximity = math.abs(Number - LowerMultiple);
  109. local UpperMultipleProximity = math.abs(Number - UpperMultiple);
  110. if LowerMultipleProximity <= UpperMultipleProximity then
  111. Number = LowerMultiple;
  112. else
  113. Number = UpperMultiple;
  114. end;
  115. return Number;
  116. end;
  117.  
  118. function PositiveIntegerMask(text)
  119. return text:gsub("[^%d.,-]+", "")
  120. end
  121.  
  122. -------main-------
  123. local weldpos = Vector3.new(0,0,0)
  124. local weldrot = Vector3.new(0,0,0)
  125. --textboxes
  126. WeldPos.Changed:Connect(function()
  127. WeldPos.Text = PositiveIntegerMask(WeldPos.Text)
  128. local bruh = {}
  129. for num in string.gmatch(WeldPos.Text, "[%-%d%.]+") do
  130. table.insert(bruh, tonumber(num));
  131. end
  132. weldpos = Vector3.new(unpack(bruh))
  133. end)
  134. WeldRot.Changed:Connect(function()
  135. WeldRot.Text = PositiveIntegerMask(WeldRot.Text)
  136. local bruh = {}
  137. for num in string.gmatch(WeldRot.Text, "[%-%d%.]+") do
  138. table.insert(bruh, tonumber(num));
  139. end
  140. weldrot = Vector3.new(unpack(bruh))
  141. end)
  142. --keybinds
  143. warn("brought to you by Austin K")
  144. Mouse.KeyDown:Connect(function(key)
  145. if key == "j" then
  146. w1 = Mouse.Target
  147. if w1.Parent:IsA("Model") then --text
  148. Weld1.Text = "Part0: " .. w1.Parent.Name
  149. else
  150. Weld1.Text = "Part0: " .. w1.Material.Name
  151. end
  152. elseif key == "u" then
  153. w2 = Mouse.Target
  154. if w2.Parent:IsA("Model") then --creating ghost model
  155. Weld2.Text = "Part1: " .. w2.Parent.Name
  156. if ghost then ghost:Destroy(); ghost = nil;square.Adornee = nil; end;
  157. ghost = w2.Parent:Clone()
  158. ghost.Parent = workspace
  159. square.Adornee = ghost:FindFirstChild(w2.Name)
  160. for _,gpart in pairs(ghost:GetChildren()) do
  161. if gpart:IsA("BasePart") or gpart:IsA("UnionOperation") or gpart:IsA("MeshPart") then
  162. gpart.Anchored = true
  163. gpart.Locked = true
  164. gpart.Transparency = 0.7
  165. gpart.CanCollide = false
  166. end
  167. end
  168. else--creating ghost part
  169. Weld2.Text = "Part1: " .. w2.Material.Name
  170. if ghost then ghost:Destroy(); ghost = nil;square.Adornee = nil; end;
  171. ghost = w2:Clone()
  172. ghost.Parent = workspace
  173. ghost.Anchored = true
  174. ghost.Locked = true
  175. ghost.CanCollide = false
  176. ghost.Transparency = 0.7
  177. square.Adornee = ghost
  178. Mouse.TargetFilter = ghost
  179. end
  180. end
  181. end)
  182.  
  183.  
  184. --weld
  185. TextButton.MouseButton1Down:Connect(function()
  186. if Mouse.Target then
  187. print("weld")
  188. local Arguments = {
  189. [1] = w1, --part0
  190. [2] = w2, --part1
  191. [3] = CFrame.new(weldpos) * CFrame.Angles(math.rad(weldrot.X),math.rad(weldrot.Y),math.rad(weldrot.Z)), --c0
  192. [4] = CFrame.new(0,0,0), --c1
  193. [5] = 0.05 --weld height
  194. }
  195. Remote:FireServer(unpack(Arguments))
  196. wait()
  197. ghost:Destroy()
  198. ghost = nil
  199. square.Adornee = nil
  200. Weld1.Text = "Part0:"
  201. Weld2.Text = "Part1:"
  202. w1 = nil
  203. w2 = nil
  204. end
  205. end)
  206. --ghost position
  207. while true do
  208. if w2 and w1 and ghost then
  209. if ghost:IsA("Model") then
  210. if ghost.PrimaryPart then
  211. ghost:SetPrimaryPartCFrame(w1.CFrame *CFrame.new(weldpos) * CFrame.Angles(math.rad(weldrot.X),math.rad(weldrot.Y),math.rad(weldrot.Z)))
  212. end
  213. else
  214. ghost.CFrame = w1.CFrame * CFrame.new(weldpos) * CFrame.Angles(math.rad(weldrot.X),math.rad(weldrot.Y),math.rad(weldrot.Z))
  215. end
  216. end
  217. game:GetService("RunService").RenderStepped:Wait()
  218. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement