Advertisement
HanzerCopy

Script 1

Jun 13th, 2025
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | Source Code | 0 0
  1. --print("Hello, World!")
  2. local TweenService = game:GetService("TweenService") -- Perbaikan di sini: 'Local' menjadi 'local'
  3. local part = script.Parent -- Asumsikan script ditempel di part
  4. -- Konfigurasi animasi
  5. local RISE_HEIGHT = 25 -- Ketinggian naik (studs)
  6. local RISE_DURATION = 1.5 -- Durasi naik (detik)
  7. local FALL_DURATION = 1.5 -- Durasi turun (detik)
  8. local HOLD_TIME = 3 -- Waktu bertahan di atas (detik)
  9. local EASING_STYLE_UP = Enum.EasingStyle.Quad -- Gaya animasi naik
  10. local EASING_STYLE_DOWN = Enum.EasingStyle.Quad -- Gaya animasi turun
  11. local isAnimating = false -- Variabel debounce: true jika animasi sedang berjalan
  12. local debounceTime = 0.5 -- Waktu tunggu (detik) setelah animasi selesai sebelum bisa dipicu lagi
  13. local originalPosition = part.Position -- Simpan posisi awal
  14. local function riseBlock()
  15.     if isAnimating then -- Jika sedang animasi, keluar dari fungsi
  16.         return
  17.     end
  18.     isAnimating = true -- Set debounce menjadi true, menandakan animasi dimulai
  19.    
  20.     -- Hitung posisi baru
  21.     local targetPosition = originalPosition + Vector3.new(0, RISE_HEIGHT, 0)
  22.    
  23.     -- Buat tween naik
  24.     local tweenInfoUp = TweenInfo.new(
  25.     RISE_DURATION,
  26.     EASING_STYLE_UP,
  27.     Enum.EasingDirection.Out
  28.     )
  29.    
  30.     local riseTween = TweenService:Create(part, tweenInfoUp, {Position = targetPosition})
  31.     riseTween:Play()
  32.    
  33.     -- Tunggu sampai selesai naik
  34.     riseTween.Completed:Wait()
  35.    
  36.     -- Tunggu beberapa detik di atas
  37.     task.wait(HOLD_TIME) -- Menggunakan task.wait()
  38.    
  39.     -- Buat tween turun
  40.     local tweenInfoDown = TweenInfo.new(
  41.     FALL_DURATION,
  42.     EASING_STYLE_DOWN,
  43.     Enum.EasingDirection.Out
  44.     )
  45.    
  46.     local fallTween = TweenService:Create(part, tweenInfoDown, {Position = originalPosition})
  47.     fallTween:Play()
  48.     fallTween.Completed:Wait()
  49.    
  50.     -- Setelah animasi selesai, tunggu debounceTime sebelum reset isAnimating
  51.     task.wait(debounceTime) -- Menggunakan task.wait()
  52.     isAnimating = false -- Reset debounce, agar bisa dipicu lagi
  53. end -- Penutup fungsi riseBlock() perlu ada di sini, di akhir definisinya.
  54.  
  55. part.Touched:Connect(function(hit)
  56.     -- Cek jika player yang menyentuh DAN animasi tidak sedang berjalan
  57.     if hit.Parent:FindFirstChild("Humanoid") and not isAnimating then
  58.         riseBlock()
  59.     end
  60. end)
  61.  
  62. -- Optional: Buat part berwarna untuk visualisasi
  63. -- part.BrickColor = BrickColor.new("Bright blue") -- Dihapus agar warna asli part tetap
  64. part.Material = Enum.Material.Neon
  65. part.Anchored = true -- Pastikan anchored agar tidak jatuh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement