Advertisement
AALTTz

werd

Apr 7th, 2023
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. -- Define constants
  2. local MOVE_SPEED = 50 -- The speed at which the player moves
  3. local MAX_HEIGHT = 100 -- The maximum height the player will reach
  4. local MAX_SIDEWAYS_DISTANCE = 20 -- The maximum distance the player will move side to side
  5. local TIME_PER_SIDEWAY_MOVEMENT = 2 -- The time it takes to complete one sideways movement
  6.  
  7. -- Get the player and their humanoid
  8. local player = game.Players.LocalPlayer
  9. local humanoid = player.Character.Humanoid
  10.  
  11. -- Anchor the player in the sky
  12. game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(5.40754509, 26.7068005, 0.199012667, 0.0663255602, 0.0316758864, -0.997295141, 0.00561274868, 0.999468446, 0.0321182013, 0.99778229, -0.00772783346, 0.0661125109)
  13. humanoid.RootPart.Anchored = true
  14.  
  15. -- Move the player up into the sky
  16. for height = 0, MAX_HEIGHT, MOVE_SPEED do
  17. local targetPosition = humanoid.RootPart.Position + Vector3.new(0, MOVE_SPEED, 0)
  18. humanoid:MoveTo(targetPosition)
  19. wait()
  20. end
  21.  
  22. -- Move the player side to side
  23. while true do
  24. local timeStarted = os.clock()
  25. local distance = 0
  26.  
  27. -- Move the player side to side for TIME_PER_SIDEWAY_MOVEMENT seconds
  28. while distance < MAX_SIDEWAYS_DISTANCE do
  29. local timeElapsed = os.clock() - timeStarted
  30. local delta = math.min(timeElapsed / TIME_PER_SIDEWAY_MOVEMENT, 1)
  31. local angle = math.rad(time() * 180)
  32. local direction = Vector3.new(math.sin(angle), 0, math.cos(angle)) * MAX_SIDEWAYS_DISTANCE
  33. local targetCFrame = CFrame.new(humanoid.RootPart.Position + direction)
  34.  
  35. -- Move the player towards the target position
  36. humanoid.RootPart.CFrame = humanoid.RootPart.CFrame:Lerp(targetCFrame, delta)
  37. distance = distance + MOVE_SPEED * delta
  38. wait()
  39. end
  40. end
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement