Advertisement
Sungmingamerpro13

New DialogueScript (LocalScript) SungExetior13RBLX (Sungmin)

Jan 15th, 2025
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 2.60 KB | None | 0 0
  1. local Message = game.ReplicatedStorage:WaitForChild("Message")
  2. local Image = Message:WaitForChild("SpeakerImage")
  3. local Speaker = Message:WaitForChild("SpeakerName")
  4.  
  5. local player = game.Players.LocalPlayer
  6. local DialogueFrame = player.PlayerGui:WaitForChild("DialogueGui").DialogueFrame
  7.  
  8. -- Create a camera instance and attach it to the DialogueFrame
  9. local camera = Instance.new("Camera")
  10. camera.Parent = DialogueFrame
  11.  
  12. -- Variables
  13. DefaultMessageDelayTime = 4
  14. LetterInvertal = 0.05
  15. MessageWaitSigns = {',', '?', '.'}
  16. MessageWaitSignDelay = 1
  17.  
  18. -- Function to update the character display (only head and accessories)
  19. local function UpdateCharacter(character)
  20.     local worldModel = DialogueFrame.PlayerImage.Icon.WorldModel
  21.  
  22.     -- Clear existing parts in the WorldModel
  23.     for _, child in pairs(worldModel:GetChildren()) do
  24.         if child:IsA("BasePart") or child:IsA("Accessory") then
  25.             child:Destroy()
  26.         end
  27.     end
  28.  
  29.     -- Clone only the head and accessories from the character
  30.     for _, child in pairs(character:GetChildren()) do
  31.         if child:IsA("Accessory") or (child:IsA("BasePart") and child.Name == "Head") then
  32.             local clonedChild = child:Clone()
  33.             clonedChild.Parent = worldModel
  34.         end
  35.     end
  36.  
  37.     -- Set the camera to focus on the head
  38.     local head = worldModel:FindFirstChild("Head")
  39.     if head then
  40.         camera.CFrame = head.CFrame * CFrame.new(0, 0.1, -2) * CFrame.Angles(0, math.rad(180), 0)
  41.         DialogueFrame.PlayerImage.Icon.CurrentCamera = camera
  42.     else
  43.         warn("Head not found in character!")
  44.     end
  45. end
  46.  
  47. local function Animate(Text, MessageDelayTime)
  48.     for i = 1,#Text,1 do
  49.         DialogueFrame.Dialogue.Text = string.sub(Text,1,i)
  50.         script.DialogueSound:Play()
  51.         for _, L in pairs(MessageWaitSigns) do
  52.             if string.sub(Text,i,i) == L then
  53.                 wait(MessageWaitSignDelay)
  54.             end
  55.         end
  56.         wait(LetterInvertal)
  57.     end
  58.     if tonumber(MessageDelayTime) ~= nil then
  59.         wait(MessageDelayTime)
  60.     else
  61.         wait(DefaultMessageDelayTime)
  62.     end
  63.     DialogueFrame:TweenPosition(UDim2.new(0.55, 0, -1, 0))
  64. end
  65.  
  66. -- Update the dialogue text when the message changes
  67. Message:GetPropertyChangedSignal("Value"):Connect(function()
  68.     DialogueFrame:TweenPosition(UDim2.new(0.55, 0, 0.15, 0))
  69.     Animate(Message.Value)
  70. end)
  71.  
  72. -- Update the speaker and character display when the speaker changes
  73. Speaker:GetPropertyChangedSignal("Value"):Connect(function()
  74.     print("New Speaker: " .. Speaker.Value)
  75.  
  76.     local character = workspace:FindFirstChild(Image.Value)
  77.     if character then
  78.         UpdateCharacter(character)
  79.     else
  80.         warn("Character not found in workspace: " .. Image.Value)
  81.     end
  82.  
  83.     DialogueFrame.PlayerImage.Icon.nameLabel.Text = Speaker.Value
  84. end)
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement