I’m trying to make a dialog ui where it would have the NPC’s body on a viewport frame,
but the problem is that the camera’s CFrame doesn’t change to the CFrame of the character?
--[[
dialog service in serverstorage to prevent exploiters from having fun - made by lam
]]
local module = {}
local replicatedstorage = game:GetService('ReplicatedStorage')
local signalservice = require(replicatedstorage.Services.GoodSignal)
local tweenservice = game:GetService('TweenService')
local twninfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false
)
function module.start(player,name:string,face:Instance,choice1:string,choice2:string,choice3:string,sentence:string)
local tabl = {
['name'] = name,
['face'] = face,
['choices'] = {
[1] = choice1,
[2] = choice2,
[3] = choice3
},
['sentence'] = sentence
}
script.dialog.Parent = player:WaitForChild('PlayerGui')
return tabl
end
local function typeText(instance, text)
local sig = signalservice.new()
local symbols = {'!','?','.',','}
for i = 1, #text, 1 do
instance.Text = string.sub(text, 1, i)
for i, symbol in pairs(symbols) do
if string.sub(text, 1, i):match(symbol) then
task.wait(1)
else
task.wait(0.01)
end
end
end
--sig:Fire(true)
return true --sig:Wait()
end
local function filterChoices(player,tabl)
local playergui = player:WaitForChild('PlayerGui')
local dialog = playergui:WaitForChild('dialog').container
local choicesUI = dialog.buttonContainer
if not tabl['choices'][1] then
choicesUI:WaitForChild('1').Visible = false
else
choicesUI:WaitForChild('1').Visible = true
choicesUI:WaitForChild('1').textlabel.Text = tabl['choices'][1]
end
if not tabl['choices'][2] then
choicesUI:WaitForChild('2').Visible = false
else
choicesUI:WaitForChild('2').Visible = true
choicesUI:WaitForChild('2').textlabel.Text = tabl['choices'][2]
end
if not tabl['choices'][3] then
choicesUI:WaitForChild('3').Visible = false
else
choicesUI:WaitForChild('3').Visible = true
choicesUI:WaitForChild('3').textlabel.Text = tabl['choices'][3]
end
end
function module:startdialog(player:Player,edits)
local signal = signalservice.new()
local playergui = player:WaitForChild('PlayerGui')
local dialog = playergui:WaitForChild('dialog').container
local buttonContainer = dialog.buttonContainer
local enterTween = tweenservice:Create(dialog,twninfo,{['Size'] = UDim2.fromScale(0.427,0.25)})
local exitTween = tweenservice:Create(dialog,twninfo,{['Size'] = UDim2.fromScale(0,0)})
local function playFadeOut()
task.spawn(function()
for _, v in pairs(buttonContainer:GetChildren()) do
if v:IsA('TextButton') then
local twen = tweenservice:Create(v,twninfo,{['BackgroundTransparency'] = 0})
local texttwen = tweenservice:Create(v.textlabel,twninfo,{['TextTransparency'] = 0})
twen:Play()
texttwen:Play()
end
end
end)
end
dialog.name.TextLabel.Text = edits['name']
local viewport = dialog.ViewportFrame
local character = edits['face']
character.Parent = viewport
local camera = Instance.new('Camera')
camera.CameraType = 'Custom'
camera.Name = 'viewportCamera'
camera.Parent = dialog.ViewportFrame
local root = edits['face']:WaitForChild('HumanoidRootPart')
camera.CFrame = CFrame.new(root.Position,(root.CFrame.lookVector*2),root.Position)
viewport.CurrentCamera = camera
warn(camera.CFrame)
warn(root.CFrame)
filterChoices(player,edits)
enterTween:Play()
local status = typeText(dialog.TextLabel,edits['sentence'])
if status then
filterChoices(player,edits)
playFadeOut()
end
for _, v in pairs(buttonContainer:GetChildren()) do
if v:IsA('TextButton') and v.Name ~= 'goodbye' then
v.MouseButton1Click:Connect(function()
signal:Fire(v.Name)
end)
end
end
return signal:Wait()
end
function module:normalDialogStart(player,edits)
end
return module
what line 114 and 115 print:
