Advertisement
Sungmingamerpro13

New DialogueScript Update (SungExetior13RBLX Style)

Nov 15th, 2024 (edited)
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 2.28 KB | None | 0 0
  1. local Message = game.ReplicatedStorage:WaitForChild("Message")
  2. local Image = Message:WaitForChild("SpeakerImage")
  3. local Speaker = Message:WaitForChild("SpeakerName")
  4. local HideDialogueEvent = Message:WaitForChild("HideDialogueEvent")
  5.  
  6. local player = game.Players.LocalPlayer
  7. local DialogueFrame = player.PlayerGui:WaitForChild("DialogueGui").DialogueFrame
  8.  
  9. -- Create a camera instance and attach it to the DialogueFrame
  10. local camera = Instance.new("Camera")
  11. camera.Parent = DialogueFrame
  12.  
  13. -- Function to update the character display (only head and accessories)
  14. local function UpdateCharacter(character)
  15.     local worldModel = DialogueFrame.PlayerImage.Icon.WorldModel
  16.  
  17.     -- Clear existing parts in the WorldModel
  18.     for _, child in pairs(worldModel:GetChildren()) do
  19.         if child:IsA("BasePart") or child:IsA("Accessory") then
  20.             child:Destroy()
  21.         end
  22.     end
  23.  
  24.     -- Clone only the head and accessories from the character
  25.     for _, child in pairs(character:GetChildren()) do
  26.         if child:IsA("Accessory") or (child:IsA("BasePart") and child.Name == "Head") then
  27.             local clonedChild = child:Clone()
  28.             clonedChild.Parent = worldModel
  29.         end
  30.     end
  31.  
  32.     -- Set the camera to focus on the head
  33.     local head = worldModel:FindFirstChild("Head")
  34.     if head then
  35.         camera.CFrame = head.CFrame * CFrame.new(0, 0.2, -2) * CFrame.Angles(0, math.rad(180), 0)
  36.         DialogueFrame.PlayerImage.Icon.CurrentCamera = camera
  37.     else
  38.         warn("Head not found in character!")
  39.     end
  40. end
  41.  
  42. -- Hide the dialogue frame when the event is triggered
  43. HideDialogueEvent.OnClientEvent:Connect(function()
  44.     DialogueFrame:TweenPosition(UDim2.new(0.55, 0, -1, 0))
  45. end)
  46.  
  47. -- Update the dialogue text when the message changes
  48. Message:GetPropertyChangedSignal("Value"):Connect(function()
  49.     DialogueFrame:TweenPosition(UDim2.new(0.55, 0, 0.139, 0))
  50.     DialogueFrame.Dialogue.Text = Message.Value
  51.     script.DialogueSound:Play()
  52. end)
  53.  
  54. -- Update the speaker and character display when the speaker changes
  55. Speaker:GetPropertyChangedSignal("Value"):Connect(function()
  56.     print("New Speaker: " .. Speaker.Value)
  57.  
  58.     local character = workspace:FindFirstChild(Image.Value)
  59.     if character then
  60.         UpdateCharacter(character)
  61.     else
  62.         warn("Character not found in workspace: " .. Image.Value)
  63.     end
  64.  
  65.     DialogueFrame.PlayerImage.Icon.nameLabel.Text = Speaker.Value
  66. end)
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement