I’m currentely using a module + viewport frame setup to get animations to play on characters in an animation wheel. Everything works fine, no errors, but the animations arent showing up? I’m using a worldmodel and cloning everything in, not sure why it isnt working.
Module code;
local emoteFolder = game.ReplicatedStorage:WaitForChild("Emotes")
local template = script:WaitForChild("tempViewport")
local emoteV = {}
function emoteV.Get(emoteName)
local newTemp = template:Clone()
local oldNPC = script:FindFirstChild("R6"):Clone()
local NPC = Instance.new("WorldModel")
oldNPC.Parent = NPC
NPC.Parent = newTemp
for i, part in oldNPC:GetChildren() do
part:Clone()
part.Parent = NPC
end
oldNPC:Destroy()
NPC.Name = emoteName
local hum = NPC:FindFirstChild("Humanoid")
local animator = hum:FindFirstChild("Animator")
if emoteFolder:FindFirstChild(emoteName) then
if newTemp and NPC and hum and animator then
local emote = emoteFolder:FindFirstChild(emoteName)
NPC.Parent = workspace
local emoteTrack = animator:LoadAnimation(emote)
NPC.Parent = newTemp
emoteTrack.Looped = true
emoteTrack:Play()
print(animator:GetPlayingAnimationTracks())
print(emoteTrack.IsPlaying)
return newTemp
end
end
end
return emoteV
Localscript code;
local gui = script.Parent
local holder = gui:WaitForChild("EmoteBG")
local emoteFolder = holder:WaitForChild("Emotes")
local uis = game.UserInputService
local viewportMod = require(game.ReplicatedStorage:WaitForChild("emoteViewport"))
local goodSize = UDim2.new(0.723, 0, 0.723, 0)
local goodPos = UDim2.new(0.14, 0, 0.19, 0)
local function setupEmotes()
for i, frame in emoteFolder:GetChildren() do
if frame.EmoteName.Text then
if not frame:FindFirstChild("tempViewport") then
local viewport = viewportMod.Get(frame.EmoteName.Text)
viewport.Size = goodSize
viewport.Position = goodPos
viewport.Parent = frame
end
end
end
end
for i, child in emoteFolder:GetChildren() do
if child:IsA("Frame") then
child.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
print(child.EmoteName.Text)
end
end)
end
end
uis.InputBegan:Connect(function(input, gpe)
if not gpe then
if input.KeyCode == Enum.KeyCode.Z then
holder.Visible = not holder.Visible
end
end
end)
holder.Changed:Connect(function(property)
if property == "Visible" then
setupEmotes()
end
end)
task.wait(1)
setupEmotes()
If anyone sees any issues or can give me some insight, that would be great!