SHARE
    TWEET
    bookedsam

    Popup Part w/ Multiple Texts

    Apr 20th, 2025 (edited)
    555
    0
    Never
    1
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    Lua 4.50 KB | None | 0 0
    1. -- openStudio Popup Parts
    2. -- Local Popup Handler
    3. -- Build 3.5 Multiple Texts 20/4/25
    4. -- // CONFIG
    5. -- i️i️ Watch the tutorial by @bookedsam for help configuring the system. i️i️
    6. local config = { -- Change these settings how you like. Settings are case sensitive.
    7. -- The name of the theme. Included themes:
    8. -- "Classic light" "Classic dark" "Bubbly" "Code" "Modern" "Transparent"
    9. ["Theme"] = "Classic light",
    10. -- The type of animation. Included animations:
    11. -- "Fade" "Typewriter" "Bounce"
    12. ["Animation"] = "Typewriter",
    13. -- Set to false if you want it to only work once.
    14. ["Repeat"] = true
    15. }
    16. -- ⚠️⚠️ ONLY EDIT BEYOND THIS POINT IF YOU KNOW WHAT YOU ARE DOING ⚠️⚠️
    17. -- // VARIABLES
    18. local ReplicatedStorage = game:GetService("ReplicatedStorage")
    19. local TweenService = game:GetService("TweenService")
    20. local Players = game:GetService("Players")
    21. local themes = ReplicatedStorage:WaitForChild("openPopup")
    22. local partFolder = workspace:WaitForChild("openPopup")
    23. local label = nil
    24. local labelSave = nil
    25. local animations = {}
    26. -- // FUNCTIONS
    27. -- Animation that fades in and out the text.
    28. animations.Fade = function(text: string)
    29. local info = TweenInfo.new(1)
    30. local fadeIn = TweenService:Create(label, info,
    31. {BackgroundTransparency = labelSave.BackgroundTransparency,
    32. TextTransparency = labelSave.TextTransparency})
    33. local fadeOut = TweenService:Create(label, info,
    34. {BackgroundTransparency = 1,
    35. TextTransparency = 1})
    36. label.Transparency = 1
    37. fadeIn:Play()
    38. fadeIn.Completed:Wait()
    39. task.wait(string.len(text) / 20)
    40. fadeOut:Play()
    41. fadeOut.Completed:Wait()
    42. end
    43. -- Animation that has a typing effect.
    44. animations.Typewriter = function(text: string)
    45. local infoType = TweenInfo.new(string.len(text) / 10, Enum.EasingStyle.Linear)
    46. local infoFade = TweenInfo.new(0.5)
    47. local typeIn = TweenService:Create(label, infoType, {MaxVisibleGraphemes = string.len(text)})
    48. local fadeIn = TweenService:Create(label, infoFade, {BackgroundTransparency = labelSave.BackgroundTransparency})
    49. local fadeOut = TweenService:Create(label, infoFade, {BackgroundTransparency = 1, TextTransparency = 1})
    50. label.TextTransparency = 0
    51. label.MaxVisibleGraphemes = 0
    52. label.BackgroundTransparency = 1
    53. fadeIn:Play()
    54. typeIn:Play()
    55. typeIn.Completed:Wait()
    56. task.wait(string.len(text) / 20)
    57. fadeOut:Play()
    58. fadeOut.Completed:Wait()
    59. end
    60. -- Animation where the text object jumps into frame.
    61. animations.Bounce = function(text: string)
    62. local info = TweenInfo.new(0.5, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
    63. local bounceIn = TweenService:Create(label, info, {Size = labelSave.Size})
    64. local bounceOut = TweenService:Create(label, info, {Size = UDim2.new(0, 0, 0 ,0)})
    65. label.Size = UDim2.new(0, 0, 0, 0)
    66. bounceIn:Play()
    67. bounceIn.Completed:Wait()
    68. task.wait(string.len(text) / 20)
    69. bounceOut:Play()
    70. bounceOut.Completed:Wait()
    71. end
    72. local function setupPart(part)
    73. if part:IsA("Part") then
    74. for _, e in ipairs(part:GetChildren()) do
    75. if e:IsA("Decal") then e:Destroy() end
    76. end
    77. local texts = {}
    78. for _, v in ipairs(part:GetChildren()) do
    79. if v:IsA("StringValue") then
    80. texts[tonumber(v.Name)] = v.Value
    81. end
    82. end
    83. local debounce = false
    84. local connection
    85. connection = part.Touched:Connect(function(touch)
    86. if Players:GetPlayerFromCharacter(touch.Parent) == Players.LocalPlayer then
    87. if debounce then return end
    88. debounce = true
    89. for i, v in ipairs(texts) do
    90. label.Text = v
    91. label.Visible = true
    92. animations[config.Animation](v)
    93. end
    94. label.Visible = false
    95. task.wait(1)
    96. if config.Repeat then debounce = false else connection:Disconnect() end
    97. end
    98. end)
    99. end
    100. end
    101. -- // SETUP
    102. if not animations[config.Animation] then
    103. warn("[openPopup] The animation you set could not be found! Defaulting to 'Fade'.")
    104. config.Animation = "Fade"
    105. end
    106. if not themes:WaitForChild(config.Theme, 1) then
    107. warn("[openPopup] The theme you set could not be found! Defaulting to 'Classic light'")
    108. config.Theme = "Classic light"
    109. end
    110. label = themes:WaitForChild(config.Theme):Clone()
    111. label.Visible = false
    112. label.Parent = script.Parent
    113. labelSave = themes:WaitForChild(config.Theme)
    114. print("[openPopup] openStudio Popup System ready. Have any errors? Contact @bookedsam.")
    115. -- // MAIN
    116. task.wait(1)
    117. for _, v in ipairs(partFolder:GetChildren()) do
    118. setupPart(v)
    119. end
    120. partFolder.ChildAdded:Connect(function(part)
    121. setupPart(part)
    122. end)
    Advertisement
    Comments
    • bookedsam
      260 days (edited)
      # text 0.09 KB | 0 0
      1. To make this work, change the name of each text element to 1, 2, etc under each popup part.
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /