let me make this clear i have a dialog box and you click to show the npc's dialog and then when you finished talking to the npc and try to click it again it won't show. here's the script i am working with
while not script.Parent:findFirstChild("Ready") do wait() end wait()
--initial setup local camtweened = false local cam = workspace.CurrentCamera local origcf = cam.CoordinateFrame local currentcf = origcf local camtweenframes = 20
local frame = script.Parent.Frame for i,object in ipairs(frame:GetChildren()) do object.BackgroundColor3 = script.Dialog.ChatColor.Value.Color end frame.Icon.Image = script.Dialog.Icon.Texture frame.NPCName.Text = script.Dialog.NPCName.Value frame.Text.Text = ". . ."
local basechoice = frame.Choice:clone() frame.Choice:Destroy()
function tweencamerato(startcf,endcf,frames) local rota = Vector3.new(startcf:toEulerAnglesXYZ()) local rotb = Vector3.new(endcf:toEulerAnglesXYZ()) local cf for frame=1,frames do local rot = rota:Lerp(rotb,frame/frames) cf = CFrame.new(startcf.p:Lerp(endcf.p,frame/frames)) * CFrame.Angles(rot.X,rot.Y,rot.Z) local sx, sy, sz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components() local bank = math.atan2(m10, m11) cam.CoordinateFrame = cf --cam:SetRoll(bank) <-- uncomment this if you want your camera to roll wait(0) end currentcf = cf end
function progressdialog(choice)
--clean up old choices
for i,oldchoice in ipairs(frame:GetChildren()) do
if oldchoice.Name == "Choice" then
oldchoice:Destroy()
wait()
end
end
--check for TWEENCAMERA flag
if choice:findFirstChild("TWEENCAMERA") then
cam.CameraType = Enum.CameraType.Scriptable
tweencamerato(currentcf,choice.TWEENCAMERA.Value,camtweenframes)
currentcf = choice.TWEENCAMERA.Value
camtweened = true
end
--dislpay response
for letter=1,string.len(choice.Value) do
frame.Text.Text = string.sub(choice.Value,1,letter)
wait(script.Dialog.ReadSpeed.Value)
end
wait(0.5)
if #choice:GetChildren() == 0 then --no more options
if camtweened then
tweencamerato(currentcf,origcf,camtweenframes)
end
script.Parent.Name = "CleaningUp"
cam.CameraType = Enum.CameraType.Custom
wait(2)
frame:TweenPosition(UDim2.new(0.5, -150, 0, -100), "Out", "Elastic", 2)
wait(2)
script.Parent:Destroy() --clean up gui
else --theres still more options, display them
for i,newchoice in ipairs(choice:GetChildren()) do
if newchoice.Name ~= "NEEDSITEM" and newchoice.Name ~= "TWEENCAMERA" and newchoice:IsA("StringValue") then --normal dialog choice
--check for NEEDSITEM flag
if newchoice:findFirstChild("NEEDSITEM") and not game.Players.LocalPlayer.Backpack:findFirstChild(newchoice.NEEDSITEM.Value) then
return --player does not have needed item, do not display choice
end
--display buttons
local newchoicebutton = basechoice:clone()
newchoicebutton.Parent = frame
newchoicebutton.Text = newchoice.Name
newchoicebutton.Position = UDim2.new(0,0,1,30*(#frame:GetChildren()-3)-20)
newchoicebutton.MouseButton1Down:connect(function()
--run any scripts
for i,sc in ipairs(newchoice:GetChildren()) do
if sc:IsA("BaseScript") then
sc.Disabled = false
end
end
--display new options
progressdialog(newchoice)
end)
wait()
end
end
end
end
--begin dialog frame:TweenPosition(UDim2.new(0.5, -150, 0.5, -100), "Out", "Elastic", 2) wait(2.1) progressdialog(script.Dialog.InitialGreeting)
