Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Message = game.ReplicatedStorage:WaitForChild("Message")
- local Image = Message:WaitForChild("SpeakerImage")
- local Speaker = Message:WaitForChild("SpeakerName")
- local HideDialogueEvent = Message:WaitForChild("HideDialogueEvent")
- local player = game.Players.LocalPlayer
- local DialogueFrame = player.PlayerGui:WaitForChild("DialogueGui").DialogueFrame
- -- Create a camera instance and attach it to the DialogueFrame
- local camera = Instance.new("Camera")
- camera.Parent = DialogueFrame
- -- Function to update the character display (only head and accessories)
- local function UpdateCharacter(character)
- local worldModel = DialogueFrame.PlayerImage.Icon.WorldModel
- -- Clear existing parts in the WorldModel
- for _, child in pairs(worldModel:GetChildren()) do
- if child:IsA("BasePart") or child:IsA("Accessory") then
- child:Destroy()
- end
- end
- -- Clone only the head and accessories from the character
- for _, child in pairs(character:GetChildren()) do
- if child:IsA("Accessory") or (child:IsA("BasePart") and child.Name == "Head") then
- local clonedChild = child:Clone()
- clonedChild.Parent = worldModel
- end
- end
- -- Set the camera to focus on the head
- local head = worldModel:FindFirstChild("Head")
- if head then
- camera.CFrame = head.CFrame * CFrame.new(0, 0.2, -2) * CFrame.Angles(0, math.rad(180), 0)
- DialogueFrame.PlayerImage.Icon.CurrentCamera = camera
- else
- warn("Head not found in character!")
- end
- end
- -- Hide the dialogue frame when the event is triggered
- HideDialogueEvent.OnClientEvent:Connect(function()
- DialogueFrame:TweenPosition(UDim2.new(0.55, 0, -1, 0))
- end)
- -- Update the dialogue text when the message changes
- Message:GetPropertyChangedSignal("Value"):Connect(function()
- DialogueFrame:TweenPosition(UDim2.new(0.55, 0, 0.139, 0))
- DialogueFrame.Dialogue.Text = Message.Value
- script.DialogueSound:Play()
- end)
- -- Update the speaker and character display when the speaker changes
- Speaker:GetPropertyChangedSignal("Value"):Connect(function()
- print("New Speaker: " .. Speaker.Value)
- local character = workspace:FindFirstChild(Image.Value)
- if character then
- UpdateCharacter(character)
- else
- warn("Character not found in workspace: " .. Image.Value)
- end
- DialogueFrame.PlayerImage.Icon.nameLabel.Text = Speaker.Value
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement