Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. local RunService = game:GetService("RunService")
  2. local character = script.Parent
  3. local HRP = character:WaitForChild("HumanoidRootPart")
  4. local springScript1 = require(game.ReplicatedStorage.SpringModule1)
  5. local springScript2 = require(game.ReplicatedStorage.SpringModule2)
  6.  
  7. local part1 = game.Workspace.Part1
  8. local part2 = game.Workspace.Part2
  9.  
  10. local spring1 = springScript1.new(Vector3.new(), Vector3.new(), Vector3.new(), 15, 2)
  11. local spring2 = springScript2.new(Vector3.new(), Vector3.new(), Vector3.new(), 15, 2)
  12.  
  13. local orbitTime = 30
  14. local radius = 5
  15. local eclipse = 1
  16. local rotation = CFrame.Angles(0, 0, 0)
  17.  
  18. local sin, cos = math.sin, math.cos
  19. local rotationSpeed = math.pi * 2/orbitTime
  20. eclipse = eclipse * radius
  21. local rot1 = 0
  22. local rot2 = 180
  23.  
  24. local function renderPart1(deltaTime)
  25.     spring1.target = HRP.Position - Vector3.new(-3, 0, 0)
  26.     part1.Position = spring1.p
  27.     spring1:Update(deltaTime)
  28.    
  29.     rot1 = rot1 + deltaTime * rotationSpeed
  30.     part1.CFrame = rotation * CFrame.new(sin(rot1) * eclipse, 0, cos(rot1) * radius) + HRP.Position
  31.    
  32. end
  33. RunService.RenderStepped:Connect(renderPart1)
  34.  
  35. local function renderPart2(deltaTime)
  36.     spring2.target = HRP.Position - Vector3.new(3, 0, 0)
  37.     part2.Position = spring2.p
  38.     spring2:Update(deltaTime)
  39.    
  40.     rot2 = rot2 + deltaTime * rotationSpeed
  41.     part2.CFrame = rotation * CFrame.new(sin(rot2) * eclipse, 0, cos(rot2) * radius) + HRP.Position
  42. end
  43. RunService.RenderStepped:Connect(renderPart2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement