#Dialog system error

1 messages · Page 1 of 1 (latest)

patent copper
#

local Anims = script.Parent.Anims
local Sounds = script.Parent.Sounds
local TVFrame = script.Parent.TVFrame
local DialogFrame = script.Parent.DialogFrame
local DialogText = DialogFrame.DialogText
local TemplateR6 = TVFrame.TemplateR6.WorldModel.TemplateR6
local Nickname = TVFrame.Nickname

local humanoid = TemplateR6:FindFirstChildOfClass("Humanoid")

if not humanoid then
warn("Humanoid não encontrado em", TemplateR6:GetFullName())
return
end

local animator = humanoid:FindFirstChildOfClass("Animator")

if not animator then
animator = Instance.new("Animator")
animator.Parent = humanoid
print("Animator criado")
end

-- Pré-carrega a animação (evita lag na primeira vez)
local idleAnim1 = Anims.Soldier1.Idle1

-- Aguarda a animação carregar.
animator:LoadAnimation(Anims.Soldier1.Idle1).Loaded:Wait()

-- Function do diálogo
local function showDialog(nickname, voiceSound, text, animation)
-- Parar a animação antiga.
if animation and animation.IsPlaying then
animation:Stop()
end

-- Anim
if animation then
    animation:Play()
end

-- Sound
if voiceSound then
    voiceSound:Play()
end

-- Mostra texto
DialogText.Text = text
Nickname.Text = nickname

end

-- Template de diálogo
--showDialog(Sounds.Soldier1.Voice1, "Hi, just testing...", idleAnim)

showDialog("Soldier", Sounds.Soldier1.Voice1, "Hi, just testing...", idleAnim1)

sweet crater
#

this line:
animator:LoadAnimation(Anims.Soldier1.Idle1).Loaded:Wait()
you use the function wrong

local idleAnim1 = Anims.Soldier1.Idle1
local track animator:LoadAnimation(idleAnim1)
that is all you need