Advertisement
Cat_in_the_hat

Arrow pointer

Nov 3rd, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. local targetPosition = Vector3.new(345,69,339)
  2. local offset = Vector3.new(0, 0, -3)
  3. local speed = 0.00001
  4.  
  5. local function attachPartsToPlayer(player)
  6. local entity = player:getEntity()
  7. if not entity then return end
  8.  
  9. local pointerMiddle = PartService.createPart(ItemType.CLAY_BLACK, entity:getCFrame().Position + offset)
  10. pointerMiddle:setSize(Vector3.new(0.5, 0.5, 3.9))
  11. pointerMiddle:setCollidable(false)
  12. pointerMiddle:setAnchored(true)
  13. pointerMiddle:setTransparency(0)
  14.  
  15. local leftPointerOffset = Vector3.new(-0.9, 0, -1)
  16. local rightPointerOffset = Vector3.new(0.9, 0, -1)
  17. local pointerSize = Vector3.new(0.5, 0.5, 2.5)
  18.  
  19. local leftPointer = PartService.createPart(ItemType.CLAY_BLACK, entity:getCFrame().Position + offset + leftPointerOffset)
  20. leftPointer:setSize(pointerSize)
  21. leftPointer:setCollidable(false)
  22. leftPointer:setAnchored(true)
  23. leftPointer:setTransparency(0)
  24.  
  25. local rightPointer = PartService.createPart(ItemType.CLAY_BLACK, entity:getCFrame().Position + offset + rightPointerOffset)
  26. rightPointer:setSize(pointerSize)
  27. rightPointer:setCollidable(false)
  28. rightPointer:setAnchored(true)
  29. rightPointer:setTransparency(0)
  30.  
  31. local function updatePartPosition()
  32. while entity and entity:isAlive() do
  33. local playerCFrame = entity:getCFrame()
  34.  
  35. pointerMiddle:setCFrame(playerCFrame * CFrame.new(offset))
  36. rightPointer:setCFrame(playerCFrame * CFrame.new(rightPointerOffset))
  37. leftPointer:setCFrame(playerCFrame * CFrame.new(leftPointerOffset))
  38.  
  39. local lookAtCFrame = CFrame.lookAt(pointerMiddle:getPosition(), targetPosition)
  40. pointerMiddle:setCFrame(lookAtCFrame)
  41.  
  42. rightPointer:setCFrame(lookAtCFrame * CFrame.new(rightPointerOffset) * CFrame.Angles(0, math.rad(-135), 0))
  43. leftPointer:setCFrame(lookAtCFrame * CFrame.new(leftPointerOffset) * CFrame.Angles(0, math.rad(135), 0))
  44.  
  45. task.wait(speed)
  46. end
  47. end
  48.  
  49. task.spawn(updatePartPosition)
  50. end
  51.  
  52. for _, player in pairs(PlayerService.getPlayers()) do
  53. attachPartsToPlayer(player)
  54. end
  55.  
  56. Events.EntityDeath(function(event)
  57. local entity = event.entity
  58. if not entity then return end
  59.  
  60. local player = entity:getPlayer()
  61. if player then
  62. attachPartsToPlayer(player)
  63. end
  64. end)
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement