Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Define constants
- local MOVE_SPEED = 50 -- The speed at which the player moves
- local MAX_HEIGHT = 100 -- The maximum height the player will reach
- local MAX_SIDEWAYS_DISTANCE = 20 -- The maximum distance the player will move side to side
- local TIME_PER_SIDEWAY_MOVEMENT = 2 -- The time it takes to complete one sideways movement
- -- Get the player and their humanoid
- local player = game.Players.LocalPlayer
- local humanoid = player.Character.Humanoid
- -- Anchor the player in the sky
- 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)
- humanoid.RootPart.Anchored = true
- -- Move the player up into the sky
- for height = 0, MAX_HEIGHT, MOVE_SPEED do
- local targetPosition = humanoid.RootPart.Position + Vector3.new(0, MOVE_SPEED, 0)
- humanoid:MoveTo(targetPosition)
- wait()
- end
- -- Move the player side to side
- while true do
- local timeStarted = os.clock()
- local distance = 0
- -- Move the player side to side for TIME_PER_SIDEWAY_MOVEMENT seconds
- while distance < MAX_SIDEWAYS_DISTANCE do
- local timeElapsed = os.clock() - timeStarted
- local delta = math.min(timeElapsed / TIME_PER_SIDEWAY_MOVEMENT, 1)
- local angle = math.rad(time() * 180)
- local direction = Vector3.new(math.sin(angle), 0, math.cos(angle)) * MAX_SIDEWAYS_DISTANCE
- local targetCFrame = CFrame.new(humanoid.RootPart.Position + direction)
- -- Move the player towards the target position
- humanoid.RootPart.CFrame = humanoid.RootPart.CFrame:Lerp(targetCFrame, delta)
- distance = distance + MOVE_SPEED * delta
- wait()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement