I’m trying to create a Roblox plugin which syncs animations and VFX. However, animations seem to not be working, and when I try to play them on a rig, nothing happens. There are no errors, or anything.
I’ve tried using calling LoadAnimation on the AnimationController, Animator, and the Humanoid, but they don’t seem to work. Here’s the plugin code:
local widgetInfo = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float, -- Widget will be initialized in floating panel
true, -- Widget will be initially enabled
false, -- Don't override the previous enabled state
200, -- Default width of the floating window
300, -- Default height of the floating window
150, -- Minimum width of the floating window
150 -- Minimum height of the floating window
)
local SelectionService = game:GetService("Selection")
local currentScript
local currentAnim
local testWidget = plugin:CreateDockWidgetPluginGui("TestWidget", widgetInfo)
testWidget.Title = "Animation/VFX Syncer"
local testButton = Instance.new("TextButton")
testButton.TextColor3 = Color3.new(1, 1, 1)
testButton.AnchorPoint = Vector2.new(0.5,0.5)
testButton.BackgroundColor3 = Color3.fromRGB(85, 170, 255)
testButton.Size = UDim2.new(.9,0,.1,0)
testButton.Position = UDim2.new(0.5,0,0.5,0)
testButton.SizeConstraint = Enum.SizeConstraint.RelativeYY
testButton.Text = "Run"
testButton.Parent = testWidget
testButton.Name = "startButton"
local label = Instance.new("TextLabel")
label.TextColor3 = Color3.new(1, 1, 1)
label.AnchorPoint = Vector2.new(0.5,0.5)
label.BackgroundTransparency = 1
label.Size = UDim2.new(.9,0,.1,0)
label.Position = UDim2.new(0.5,0,0.6,0)
label.Text = "Current Script: "
label.Parent = testWidget
label.Name = "CurrentScript"
local label2 = Instance.new("TextLabel")
label2.TextColor3 = Color3.new(1, 1, 1)
label2.AnchorPoint = Vector2.new(0.5,0.5)
label2.BackgroundTransparency = 1
label2.Size = UDim2.new(.9,0,.1,0)
label2.Position = UDim2.new(0.5,0,0.7,0)
label2.Text = "Current Animation: "
label2.Parent = testWidget
label2.Name = "CurrentAnimation"
SelectionService.SelectionChanged:Connect(function()
local currentlySelectedThing = SelectionService:Get()
for _, thing in pairs(currentlySelectedThing) do
if thing.ClassName == "ModuleScript" then
currentScript = thing
label.Text = "Script: "..thing.Name
elseif thing.ClassName == "KeyframeSequence" then
currentAnim = thing
label2.Text = "Animation: "..thing.Name
end
end
end)
local loadedAnim: AnimationTrack
testButton.MouseButton1Down:Connect(function()
if not currentAnim or not currentScript then
return
end
if loadedAnim then
loadedAnim:Stop()
loadedAnim = nil
testButton.BackgroundColor3 = Color3.fromRGB(85, 170, 255)
testButton.Text = "Run"
game.Workspace:FindFirstChild("TestAnimation"):Destroy()
else
testButton.BackgroundColor3 = Color3.fromRGB(255, 85, 127)
testButton.Text = "Stop"
local asset = game.KeyframeSequenceProvider:RegisterKeyframeSequence(currentAnim)
local animation = Instance.new("Animation")
local rig = game.Workspace:FindFirstChild(currentAnim.Parent.Name)
animation.Name = "TestAnimation"
animation.AnimationId = asset
animation.Parent = workspace
loadedAnim = rig.Humanoid.Animator:LoadAnimation(animation)
loadedAnim.Looped = true
loadedAnim.Priority = Enum.AnimationPriority.Action4
loadedAnim:Play()
loadedAnim = loadedAnim
local requireScript = require(currentScript)
requireScript(loadedAnim)
end
end)