Advertisement
KrYn0MoRe

trig circle maker (funny)

Sep 24th, 2023 (edited)
864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.59 KB | None | 0 0
  1. local center_part = Instance.new("Part")
  2. center_part.Size = Vector3.new(1,1,1)
  3. center_part.Anchored = true
  4. center_part.CanCollide = true
  5. center_part.Parent = script
  6.  
  7. local offset = CFrame.new(20,20,0)
  8. center_part.CFrame = offset
  9.  
  10. local target_part = center_part:Clone()
  11. target_part.Parent = script
  12.  
  13. local hyp_part = center_part:Clone()
  14. hyp_part.Transparency = 0.5
  15. hyp_part.Color = Color3.new(1,0,0)
  16. hyp_part.Parent = script
  17.  
  18. local adj_part = center_part:Clone()
  19. adj_part.Transparency = 0.5
  20. adj_part.Color = Color3.new(0,1,0)
  21. adj_part.Parent = script
  22.  
  23. local opp_part = center_part:Clone()
  24. opp_part.Transparency = 0.5
  25. opp_part.Color = Color3.new(0,0,1)
  26. opp_part.Parent = script
  27.  
  28. local at1 = Instance.new("Attachment")
  29. at1.Position = Vector3.new(0,-0.5,0)
  30. at1.Parent = target_part
  31. local at2 = Instance.new("Attachment")
  32. at1.Position = Vector3.new(0,0.5,0)
  33. at2.Parent = target_part
  34.  
  35. local trail = Instance.new("Trail")
  36. trail.Attachment0 = at1
  37. trail.Attachment1 = at2
  38. trail.FaceCamera = true
  39. trail.Transparency = NumberSequence.new(0,1)
  40. trail.Lifetime = 1
  41. trail.MinLength = 0
  42. trail.WidthScale = NumberSequence.new(1,1)
  43. trail.Parent = target_part
  44.  
  45. local angle_change = nil
  46. local hyp_mult = 1
  47. function update()
  48.     local speed = 5
  49.     local dist = 10
  50.    
  51.     local t = os.clock()*speed
  52.    
  53.     target_part.CFrame = offset*CFrame.new(0,math.cos(t)*dist,math.sin(t)*dist)
  54.    
  55.     local pos_sub = (center_part.Position-target_part.Position)*Vector3.new(0,1,1)
  56.     local hyp = pos_sub.Magnitude
  57.     if 0 > pos_sub.Y and hyp_mult == 1 then
  58.         hyp_mult = -1
  59.        
  60.         local s = Instance.new("Sound")
  61.         s.SoundId = 'rbxassetid://2687161647'
  62.         s.Volume = 0.5
  63.         s.PlayOnRemove = true
  64.         s.Parent = target_part
  65.         s:Destroy()
  66.     elseif pos_sub.Y > 0 and hyp_mult == -1 then
  67.         hyp_mult = 1
  68.  
  69.         local s = Instance.new("Sound")
  70.         s.SoundId = 'rbxassetid://9111926008'
  71.         s.Volume = 0.5
  72.         s.PlayOnRemove = true
  73.         s.Parent = target_part
  74.         s:Destroy()
  75.     end
  76.     hyp = hyp*hyp_mult
  77.    
  78.     local adj = pos_sub.Z
  79.     -- cosA = adj/hyp, A = arccos(adj/hyp)
  80.     local angle = math.acos(adj/hyp)
  81.     angle_change = angle
  82.     -- sinA = opp/hyp, opp = hyp*sin(angle)
  83.     local opp = hyp*math.sin(angle)
  84.    
  85.     hyp_part.Size = Vector3.new(1,1,math.abs(hyp))
  86.     hyp_part.CFrame = offset*CFrame.new(0,-pos_sub.Y/2,-pos_sub.Z/2)*CFrame.Angles(angle*-1,0,0)
  87.    
  88.     adj_part.Size = Vector3.new(1,1,math.abs(adj))
  89.     adj_part.CFrame = offset*CFrame.new(0,0,-pos_sub.Z/2)*CFrame.Angles(0,0,0)
  90.    
  91.     opp_part.Size = Vector3.new(1,math.abs(opp),1)
  92.     opp_part.CFrame = offset*CFrame.new(0,-pos_sub.Y/2,-pos_sub.Z)*CFrame.Angles(0,0,0)
  93. end
  94.  
  95. while true do
  96.     task.wait()
  97.     update()
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement