Advertisement
bookedsam

Popup Part w/ Multiple Texts

Apr 20th, 2025 (edited)
231
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.  
  5. -- // CONFIG
  6.  
  7. -- ℹ️ℹ️ Watch the tutorial by @bookedsam for help configuring the system. ℹ️ℹ️
  8.  
  9. local config = { -- Change these settings how you like. Settings are case sensitive.
  10.  
  11.     -- The name of the theme. Included themes:
  12.     -- "Classic light" "Classic dark" "Bubbly" "Code" "Modern" "Transparent"
  13.     ["Theme"] = "Classic light",
  14.  
  15.     -- The type of animation. Included animations:
  16.     -- "Fade" "Typewriter" "Bounce"
  17.     ["Animation"] = "Typewriter",
  18.  
  19.     -- Set to false if you want it to only work once.
  20.     ["Repeat"] = true
  21.  
  22. }
  23.  
  24. -- ⚠️⚠️ ONLY EDIT BEYOND THIS POINT IF YOU KNOW WHAT YOU ARE DOING ⚠️⚠️
  25.  
  26. -- // VARIABLES
  27.  
  28. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  29. local TweenService = game:GetService("TweenService")
  30. local Players = game:GetService("Players")
  31.  
  32. local themes = ReplicatedStorage:WaitForChild("openPopup")
  33. local partFolder = workspace:WaitForChild("openPopup")
  34.  
  35. local label = nil
  36. local labelSave = nil
  37. local animations = {}
  38.  
  39. -- // FUNCTIONS
  40.  
  41. -- Animation that fades in and out the text.
  42. animations.Fade = function(text: string)
  43.  
  44.     local info = TweenInfo.new(1)
  45.  
  46.     local fadeIn = TweenService:Create(label, info,
  47.         {BackgroundTransparency = labelSave.BackgroundTransparency,
  48.             TextTransparency = labelSave.TextTransparency})
  49.     local fadeOut = TweenService:Create(label, info,
  50.         {BackgroundTransparency = 1,
  51.             TextTransparency = 1})
  52.  
  53.     label.Transparency = 1
  54.     fadeIn:Play()
  55.     fadeIn.Completed:Wait()
  56.     task.wait(string.len(text) / 20)
  57.     fadeOut:Play()
  58.     fadeOut.Completed:Wait()
  59.  
  60. end
  61.  
  62. -- Animation that has a typing effect.
  63. animations.Typewriter = function(text: string)
  64.  
  65.     local infoType = TweenInfo.new(string.len(text) / 10, Enum.EasingStyle.Linear)
  66.     local infoFade = TweenInfo.new(0.5)
  67.  
  68.     local typeIn = TweenService:Create(label, infoType, {MaxVisibleGraphemes = string.len(text)})
  69.  
  70.     local fadeIn = TweenService:Create(label, infoFade, {BackgroundTransparency = labelSave.BackgroundTransparency})
  71.     local fadeOut = TweenService:Create(label, infoFade, {BackgroundTransparency = 1, TextTransparency = 1})
  72.    
  73.     label.TextTransparency = 0
  74.     label.MaxVisibleGraphemes = 0
  75.     label.BackgroundTransparency = 1
  76.     fadeIn:Play()
  77.     typeIn:Play()
  78.     typeIn.Completed:Wait()
  79.     task.wait(string.len(text) / 20)
  80.     fadeOut:Play()
  81.     fadeOut.Completed:Wait()
  82.  
  83. end
  84.  
  85. -- Animation where the text object jumps into frame.
  86. animations.Bounce = function(text: string)
  87.  
  88.     local info = TweenInfo.new(0.5, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
  89.  
  90.     local bounceIn = TweenService:Create(label, info, {Size = labelSave.Size})
  91.     local bounceOut = TweenService:Create(label, info, {Size = UDim2.new(0, 0, 0 ,0)})
  92.  
  93.     label.Size = UDim2.new(0, 0, 0, 0)
  94.     bounceIn:Play()
  95.     bounceIn.Completed:Wait()
  96.     task.wait(string.len(text) / 20)
  97.     bounceOut:Play()
  98.     bounceOut.Completed:Wait()
  99.  
  100. end
  101.  
  102. local function setupPart(part)
  103.     if part:IsA("Part") then
  104.  
  105.         for _, e in ipairs(part:GetChildren()) do
  106.  
  107.             if e:IsA("Decal") then e:Destroy() end
  108.  
  109.         end
  110.  
  111.         local texts = {}
  112.  
  113.         for _, v in ipairs(part:GetChildren()) do
  114.             if v:IsA("StringValue") then
  115.                 texts[tonumber(v.Name)] = v.Value
  116.             end
  117.         end
  118.  
  119.         local debounce = false
  120.  
  121.         local connection
  122.         connection = part.Touched:Connect(function(touch)
  123.  
  124.             if Players:GetPlayerFromCharacter(touch.Parent) == Players.LocalPlayer then
  125.  
  126.                 if debounce then return end
  127.                 debounce = true
  128.  
  129.                 for i, v in ipairs(texts) do
  130.                     label.Text = v
  131.                     label.Visible = true
  132.                     animations[config.Animation](v)
  133.                 end
  134.                 label.Visible = false
  135.  
  136.                 task.wait(1)
  137.                 if config.Repeat then debounce = false else connection:Disconnect() end
  138.  
  139.             end
  140.  
  141.         end)
  142.     end
  143. end
  144.  
  145. -- // SETUP
  146.  
  147. if not animations[config.Animation] then
  148.  
  149.     warn("[openPopup] The animation you set could not be found! Defaulting to 'Fade'.")
  150.     config.Animation = "Fade"
  151.  
  152. end
  153.  
  154. if not themes:WaitForChild(config.Theme, 1) then
  155.  
  156.     warn("[openPopup] The theme you set could not be found! Defaulting to 'Classic light'")
  157.     config.Theme = "Classic light"
  158.  
  159. end
  160.  
  161. label = themes:WaitForChild(config.Theme):Clone()
  162. label.Visible = false
  163. label.Parent = script.Parent
  164. labelSave = themes:WaitForChild(config.Theme)
  165.  
  166. print("[openPopup] openStudio Popup System ready. Have any errors? Contact @bookedsam.")
  167.  
  168. -- // MAIN
  169.  
  170. task.wait(1)
  171.  
  172. for _, v in ipairs(partFolder:GetChildren()) do
  173.     setupPart(v)
  174. end
  175.  
  176. partFolder.ChildAdded:Connect(function(part)
  177.     setupPart(part)
  178. end)
Advertisement
Comments
  • bookedsam
    4 hours (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
Advertisement