BobMe

ding

Oct 5th, 2021 (edited)
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.87 KB | None | 0 0
  1. local RunService = game:GetService("RunService")
  2.  
  3. function findFirstMatchingAttachment(model, name)
  4. for _, child in pairs(model:GetChildren()) do
  5. if child:IsA("Attachment") and child.Name == name then
  6. return child
  7. elseif not child:IsA("Accoutrement") and not child:IsA("Tool") then -- don't look in hats or tools in the character
  8. local foundAttachment = findFirstMatchingAttachment(child, name)
  9. if foundAttachment then
  10. return foundAttachment
  11. end
  12. end
  13. end
  14. end
  15.  
  16. local function getOriginalProperty(obj, property)
  17. local origPropertyValue = obj:FindFirstChild("OriginalProperty" ..property)
  18. if not origPropertyValue then
  19. origPropertyValue = Instance.new("Vector3Value")
  20. origPropertyValue.Name = "OriginalProperty" ..property
  21. origPropertyValue.Value = property and obj[property]
  22. origPropertyValue.Parent = obj
  23. end
  24. return origPropertyValue.Value
  25. end
  26.  
  27. local function findHandleMesh(handle)
  28. for _, obj in pairs(handle:GetChildren()) do
  29. if obj:IsA("DataModelMesh") then
  30. return obj, getOriginalProperty(obj, "Scale")
  31. end
  32. end
  33. end
  34.  
  35. local function buildWeld(weldName, parent, part0, part1, c0, c1)
  36. local weld = Instance.new("Weld")
  37. weld.Name = weldName
  38. weld.Part0 = part0
  39. weld.Part1 = part1
  40. weld.C0 = c0
  41. weld.C1 = c1
  42. weld.Parent = parent
  43. end
  44.  
  45. local function getAccoutrementWeld(attachmentPart, handle)
  46. local accessoryWeld = handle:FindFirstChild("AccessoryWeld")
  47. if accessoryWeld then
  48. return accessoryWeld
  49. end
  50.  
  51. -- Legacy case
  52. for _, obj in pairs(attachmentPart:GetChildren()) do
  53. if obj:IsA("Weld") then
  54. if obj.Part0 == handle or obj.Part1 == handle then
  55. return obj
  56. end
  57. end
  58. end
  59.  
  60. return nil
  61. end
  62.  
  63. -- Get what part an accoutrement is attached to
  64. local function getAttachedPart(accessory, character)
  65. local handle = accessory:FindFirstChild("Handle")
  66.  
  67. if handle then
  68. local accoutrementAttachment = handle:FindFirstChildOfClass("Attachment")
  69. local characterAttachment = accoutrementAttachment and findFirstMatchingAttachment(character, accoutrementAttachment.Name) or nil
  70. local attachmentPart = characterAttachment and characterAttachment.Parent or character:FindFirstChild("Head")
  71.  
  72. return attachmentPart
  73. end
  74. return nil
  75. end
  76.  
  77. local function rescaleAccessory(accessory, character, bodyScaleVector, headScale)
  78. local handle = accessory:FindFirstChild("Handle")
  79. if not handle then
  80. return
  81. end
  82.  
  83. local originalSize = getOriginalProperty(handle, "Size")
  84. local currentScaleVector = handle.Size/originalSize
  85. local desiredScaleVector = bodyScaleVector
  86.  
  87. local accoutrementAttachment = handle:FindFirstChildOfClass("Attachment")
  88. local characterAttachment = accoutrementAttachment and findFirstMatchingAttachment(character, accoutrementAttachment.Name) or nil
  89. local attachmentPart = characterAttachment and characterAttachment.Parent or character:FindFirstChild("Head")
  90.  
  91. if not attachmentPart then
  92. return
  93. end
  94.  
  95. local accoutrementWeld = getAccoutrementWeld(attachmentPart, handle)
  96.  
  97. if attachmentPart.Name == "Head" then
  98. desiredScaleVector = Vector3.new(headScale, headScale, headScale)
  99. end
  100. local modifyVector = desiredScaleVector/currentScaleVector
  101.  
  102. -- Modify the size of the attachment and handleMesh
  103. handle.Size = handle.Size * modifyVector
  104. local handleMesh, origMeshScale = findHandleMesh(handle)
  105. if handleMesh then
  106. handleMesh.Scale = origMeshScale * desiredScaleVector
  107. end
  108.  
  109. -- This resizes the Attachment and the legacy AttachmentPoint property
  110. if accoutrementAttachment then
  111. -- Accessory case is easier
  112. accoutrementAttachment.Position = getOriginalProperty(accoutrementAttachment, "Position") * desiredScaleVector
  113. end
  114. -- Legacy hat logic case
  115. local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = accessory.AttachmentPoint:components()
  116. x, y, z = x * modifyVector.x, y * modifyVector.y, z * modifyVector.z
  117. accessory.AttachmentPoint = CFrame.new(
  118. x, y, z,
  119. R00, R01, R02,
  120. R10, R11, R12,
  121. R20, R21, R22
  122. )
  123.  
  124. local attachmentCFrame = characterAttachment and characterAttachment.CFrame or CFrame.new(0, 0.5 * headScale, 0)
  125. local hatCFrame = accoutrementAttachment and accoutrementAttachment.CFrame or accessory.AttachmentPoint
  126.  
  127. if accessory:IsA("Hat") and not accoutrementWeld.Parent == handle then
  128. -- This is using the legacy hat attachment sytem
  129. buildWeld("HeadWeld", attachmentPart, attachmentPart, handle, attachmentCFrame, hatCFrame)
  130. else
  131. -- Reparent the accessory to properly weld it to the character
  132. accessory.Parent = nil
  133. accessory.Parent = character
  134. end
  135. end
  136.  
  137. local function rescaleAccessories(character, bodyScaleVector, headScale)
  138. local humanoid = character:FindFirstChildOfClass("Humanoid")
  139. for _, obj in pairs(character:GetChildren()) do
  140. if obj:IsA("Accoutrement") then
  141. if RunService:IsServer() then
  142. rescaleAccessory(obj, character, bodyScaleVector, headScale)
  143. else
  144. -- We need to wait for character size to change
  145. local attachedPart = getAttachedPart(obj, character)
  146. local currentSize = attachedPart.Size
  147. local anyChanged, xChanged, yChanged, zChanged = false, false, false, nil
  148.  
  149. if attachedPart then
  150. coroutine.wrap(function()
  151. local sizeChangedConnection;
  152. sizeChangedConnection = attachedPart.Changed:connect(function(property)
  153. if property == "Size" then
  154. anyChanged = true
  155. if currentSize.X ~= attachedPart.Size.X then
  156. xChanged = true
  157. end
  158. if currentSize.Y ~= attachedPart.Size.Y then
  159. yChanged = true
  160. end
  161. if currentSize.Z ~= attachedPart.Size.Z then
  162. zChanged = true
  163. end
  164. end
  165.  
  166. if xChanged and yChanged and zChanged then
  167. sizeChangedConnection:disconnect()
  168. sizeChangedConnection = nil
  169. rescaleAccessory(obj, character, bodyScaleVector, headScale)
  170. end
  171. end)
  172.  
  173. -- Clean up the connection if it isn't already disconnected
  174. wait(0.5)
  175. if sizeChangedConnection then
  176. sizeChangedConnection:disconnect()
  177. end
  178. end)()
  179. end
  180. end
  181. end
  182. end
  183. end
  184.  
  185. local remote = owner:FindFirstChild("chickennuggetbuttscale")
  186. if remote == nil then remote = Instance.new("RemoteEvent",owner) remote.Name = "chickennuggetbuttscale" end
  187.  
  188. remote.OnServerEvent:Connect(function(plr,scale,body)
  189. local character = plr.Character
  190. local num = tonumber(scale)
  191. local humanoid = character:FindFirstChild("Humanoid")
  192. if humanoid and num ~= nil then
  193. if humanoid:FindFirstChild("BodyHeightScale") then
  194. humanoid.BodyHeightScale.Value = body[1]*num
  195. end
  196. if humanoid:FindFirstChild("BodyWidthScale") then
  197. humanoid.BodyWidthScale.Value = body[2]*num
  198. end
  199. if humanoid:FindFirstChild("BodyDepthScale") then
  200. humanoid.BodyDepthScale.Value = body[3]*num
  201. end
  202. if humanoid:FindFirstChild("HeadScale") then
  203. humanoid.HeadScale.Value = body[4]*num
  204. end
  205. plr.CameraMaxZoomDistance = 128*num
  206. plr.CameraMinZoomDistance = 0.5*num
  207.  
  208. rescaleAccessories(character, num*body[1], body[4]*num)
  209. for i,v in pairs(owner.Backpack:GetDescendants()) do
  210. if v:IsA("BasePart") then
  211. local g = v:FindFirstChild("realtimescale")
  212. if g == nil then
  213. g = Instance.new("Vector3Value",v)
  214. g.Name = "realtimescale"
  215. g.Value = v.Size
  216. end
  217. end
  218. end
  219. for i,v in pairs(owner.Backpack:GetDescendants()) do
  220. if v:IsA("BasePart") and v:FindFirstChild("realtimescale") ~= nil then
  221. v.Size = v.realtimescale.Value * Vector3.new(scale,scale,scale)
  222. end
  223. end
  224. end
  225. end)
  226.  
  227. NLS([[
  228. script.Parent = game.Players.LocalPlayer.PlayerScripts
  229. local locked = false
  230.  
  231. local cam = workspace.CurrentCamera
  232. cam.CameraType = Enum.CameraType.Scriptable
  233.  
  234. local runService = game:GetService("RunService")
  235. local userInputService = game:GetService("UserInputService")
  236. local deltaa = Vector2.new(0,0)
  237. local zoom = 10
  238. local sens = 0.0125
  239. local scale = 1
  240. local firstperson = false
  241. local zoomed = false
  242.  
  243. repeat wait() until game.Players.LocalPlayer.Character:FindFirstChild("Head") ~= nil and game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart") ~= nil
  244. local subtraction = game.Players.LocalPlayer.Character.Head.Position.Y - game.Players.LocalPlayer.Character.HumanoidRootPart.Position.Y
  245.  
  246. local Search
  247. function Search(Parent, Function)
  248. for Index, Object in next, Parent:children() do
  249. pcall(function()
  250. Function(Object)
  251. end)
  252. Search(Object, Function)
  253. end
  254. end
  255.  
  256. function showchar(char)
  257. coroutine.resume(coroutine.create(function()
  258. local Character = char
  259. Search(Character, function(Object)
  260. if (Object:IsA'BasePart' or Object:IsA'Decal') and Object.Name ~='HumanoidRootPart' then
  261. Object.Transparency = 0
  262. end
  263. end)
  264. end))
  265. end
  266.  
  267. function hidechar(char)
  268. coroutine.resume(coroutine.create(function()
  269. local Character = char
  270. Search(Character, function(Object)
  271. if (Object:IsA'BasePart' or Object:IsA'Decal') and Object.Name ~='HumanoidRootPart' then
  272. Object.Transparency = 1
  273. end
  274. end)
  275. end))
  276. end
  277.  
  278. coroutine.resume(coroutine.create(function()
  279. while wait() do
  280. if game.Players.LocalPlayer.Character:FindFirstChild("Head") ~= nil and game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart") ~= nil then
  281. if scale ~= game.Players.LocalPlayer.Character.Head.Size.Y then
  282. scale = game.Players.LocalPlayer.Character.Head.Size.Y
  283. subtraction = game.Players.LocalPlayer.Character.Head.Position.Y - game.Players.LocalPlayer.Character.HumanoidRootPart.Position.Y
  284. end
  285. end
  286. end
  287. end))
  288.  
  289. local function OnRenderStep()
  290. if game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart") ~= nil then
  291. if zoom > 0.65 then
  292. local delta = userInputService:GetMouseDelta()
  293. cam.CFrame = CFrame.new(game.Players.LocalPlayer.Character.HumanoidRootPart.Position + Vector3.new(0,subtraction,0))
  294. delta = Vector2.new((delta.X*sens),(delta.Y*sens))
  295. deltaa = deltaa + (delta*Vector2.new(-1,-1))
  296. cam.CFrame = cam.CFrame * CFrame.Angles(0,deltaa.X,0) * CFrame.Angles(deltaa.Y,0,0) * CFrame.new(0,0,(zoom * (scale/1)))
  297. else
  298. local delta = userInputService:GetMouseDelta()
  299. cam.CFrame = CFrame.new(game.Players.LocalPlayer.Character.HumanoidRootPart.Position + Vector3.new(0,subtraction,0))
  300. delta = Vector2.new((delta.X*sens),(delta.Y*sens))
  301. deltaa = deltaa + (delta*Vector2.new(-1,-1))
  302. cam.CFrame = cam.CFrame * CFrame.Angles(0,deltaa.X,0) * CFrame.Angles(deltaa.Y,0,0)
  303. end
  304. end
  305. end
  306.  
  307. runService:BindToRenderStep("MeasureMouseMovement", Enum.RenderPriority.Input.Value, OnRenderStep)
  308.  
  309. userInputService.InputBegan:Connect(function(input, gameProcessed)
  310. if input.UserInputType == Enum.UserInputType.MouseButton2 and not gameProcessed and zoom > 0.65 then
  311. userInputService.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
  312. elseif input.UserInputType == Enum.UserInputType.Keyboard and not gameProcessed then
  313. if input.KeyCode == Enum.KeyCode.Z and firstperson then
  314. workspace.CurrentCamera.FieldOfView = 10
  315. sens = 0.0125/10
  316. zoomed = true
  317. end
  318. end
  319. end)
  320.  
  321. userInputService.InputEnded:Connect(function(input, gameProcessed)
  322. if input.UserInputType == Enum.UserInputType.MouseButton2 and not gameProcessed and zoom > 0.65 then
  323. userInputService.MouseBehavior = Enum.MouseBehavior.Default
  324. elseif input.UserInputType == Enum.UserInputType.Keyboard and not gameProcessed then
  325. if input.KeyCode == Enum.KeyCode.Z and zoomed then
  326. workspace.CurrentCamera.FieldOfView = 70
  327. sens = 0.0125
  328. zoomed = false
  329. end
  330. end
  331. end)
  332.  
  333. userInputService.InputChanged:Connect(function(input, gameProcessed)
  334. if input.UserInputType == Enum.UserInputType.MouseWheel then
  335. if not zoomed then
  336. if zoom + (input.Position.Z * -1 * (zoom/7)) >= 0 then
  337. if zoom > 0.65 or input.Position.Z == -1 then
  338. zoom = zoom + input.Position.Z * -1 * (zoom/7)
  339. if zoom <= 0.65 and game.Players.LocalPlayer.Character:FindFirstChild("Head").Transparency ~= 1 then
  340. hidechar(game.Players.LocalPlayer.Character)
  341. userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
  342. firstperson = true
  343. elseif game.Players.LocalPlayer.Character:FindFirstChild("Head").Transparency ~= 0 then
  344. showchar(game.Players.LocalPlayer.Character)
  345. userInputService.MouseBehavior = Enum.MouseBehavior.Default
  346. firstperson = false
  347. end
  348. end
  349. end
  350. else
  351. workspace.CurrentCamera.FieldOfView = workspace.CurrentCamera.FieldOfView + ((input.Position.Z*-1)/2)
  352. sens = (workspace.CurrentCamera.FieldOfView/10) * (0.0125/10)
  353. end
  354. end
  355. end)
  356.  
  357. wait(1.1)
  358. local plr = game.Players.LocalPlayer
  359. local body = plr.Character.Humanoid.BodyHeightScale.Value
  360. local bodyw = plr.Character.Humanoid.BodyWidthScale.Value
  361. local bodyd = plr.Character.Humanoid.BodyDepthScale.Value
  362. local heads = plr.Character.Humanoid.HeadScale.Value
  363. local nearplanez = workspace.CurrentCamera.NearPlaneZ
  364. local remote = plr:WaitForChild("chickennuggetbuttscale")
  365. workspace.Gravity = 0
  366.  
  367. function changeScale(scale)
  368. remote:FireServer(scale,{body,bodyw,bodyd,heads})
  369. workspace.CurrentCamera.CameraSubject = plr.Character.Head--workspace:WaitForChild('ViewPart')
  370. local density = .3*500
  371. local friction = 100
  372. local elasticity = 0
  373. local frictionWeight = 10
  374. local elasticityWeight = 0
  375. -- Construct new PhysicalProperties and set
  376. local physProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
  377. for i,part in pairs(plr.Character:GetDescendants()) do
  378. if part:IsA("BasePart") and part.Name ~= "Head" then
  379. part.CustomPhysicalProperties = physProperties
  380. end
  381. end
  382. plr.Character.Humanoid.WalkSpeed = 16*tonumber(scale)
  383. plr.Character.Humanoid.JumpPower = 50*tonumber(scale)
  384. plr.Character.Animate.ScaleDampeningPercent.Value = 1
  385. local bf = plr.Character.HumanoidRootPart:FindFirstChild("BodyForce")
  386. if bf == nil then
  387. bf = Instance.new("BodyForce",plr.Character.HumanoidRootPart)
  388. end
  389. bf.Force = Vector3.new(0,(-350*500)*((tonumber(scale))^3.9),0)
  390. wait()
  391. wait()
  392. end
  393.  
  394. wait()
  395. changeScale(1)
  396.  
  397. plr.Chatted:Connect(function(msg)
  398. local split = string.split(msg," ")
  399. if string.lower(split[1]) == "/e" and string.lower(split[2]) == "scale" then
  400. if tonumber(split[3]) ~= nil then
  401. changeScale(tonumber(split[3])-0.01)
  402. wait(.1)
  403. changeScale(tonumber(split[3]))
  404. end
  405. end
  406. end)]],owner.PlayerGui)
  407.  
  408. NLS([[local player = game.Players.LocalPlayer
  409. local bin = Instance.new("HopperBin",player.Backpack)
  410. bin.Name = "Fly"
  411. script.Parent = bin
  412.  
  413. local char = player.Character
  414. local torso = char:FindFirstChild("HumanoidRootPart")
  415. local seleted = false
  416. local pos, gyro;
  417. local UserInputService = game:GetService("UserInputService")
  418.  
  419. bin.Selected:connect(function(mouse)
  420. selected = true
  421. pos = Instance.new("BodyPosition", torso)
  422. pos.maxForce = Vector3.new(1,1,1) * 1e99
  423. pos.position = torso.Position
  424. gyro = Instance.new("BodyGyro", torso)
  425. gyro.maxTorque = Vector3.new(1,1,1) * 1e99
  426. local angle = CFrame.new()
  427. touchstart = UserInputService.TouchStarted:connect(function()
  428. button_up = false
  429. angle = CFrame.Angles(-math.rad(70),0,0)
  430. coroutine.resume(coroutine.create(function()
  431. while not button_up do
  432. pos.position = pos.position + (mouse.Hit.p - torso.Position).unit * (10*char.Head.Size.Y)
  433. wait()
  434. end
  435. end))
  436. end)
  437. touchend = UserInputService.TouchEnded:connect(function()
  438. button_up = true
  439. angle = CFrame.new()
  440. end)
  441. mouse.Button1Down:connect(function()
  442. local button_up = false
  443. angle = CFrame.Angles(-math.rad(70),0,0)
  444. coroutine.resume(coroutine.create(function()
  445. while not button_up do
  446. pos.position = pos.position + (mouse.Hit.p - torso.Position).unit * (10*char.Head.Size.Y)
  447. wait()
  448. end
  449. end))
  450. mouse.Button1Up:wait()
  451. button_up = true
  452. angle = CFrame.new()
  453. end)
  454. while selected do
  455. gyro.cframe = CFrame.new(torso.Position, mouse.Hit.p) * angle
  456. wait()
  457. end
  458. end)
  459.  
  460. bin.Deselected:connect(function()
  461. selected = false
  462. touchstart:disconnect()
  463. touchend:Disconnect()
  464. pos:Destroy()
  465. gyro:Destroy()
  466. end)]],owner.Backpack)
Add Comment
Please, Sign In to add comment