remova a funçao de usar os templates r15 e r6 e adicione a funçao de organizador os emotes por ordem alfabetica, me de o codigo completo com as implementaçoes : -- Welcome to Animify V2
--[[
code
Version: 2.4
Documentation and API Link: https://devforum.roblox.com/t/2462029
Credits: Programmed by @4vials, designed by @ParadoxAssets
Contributors: @SaintImmor, @Bloxmaster998144
--]]
local Controller = setmetatable({}, {
__index = require(script:WaitForChild('Configuration'))
})
local Sections = {} -- cache to destroy when refreshing
-- UI Components
local AnimationGUI = script.Parent
local AnimationFrame = AnimationGUI:WaitForChild('MainFrame')
local ToggleButton = AnimationGUI:WaitForChild('toggle')
-- Dependencies
local Assets = script:WaitForChild('Assets')
local Player = game.Players.LocalPlayer
-- Animation Modules
local SectionsFolder = script:WaitForChild('Sections')
local Utility = require(script.Utility)
local function AddAnimation(sectionName: string, animationTitle: string, animationID: number)
task.defer(function()
local section = Sections[sectionName] or AddSection(sectionName)
code
Assistant
local newButton = Assets.AnimationButton:Clone()
newButton.Parent = AnimationFrame.Content.ScrollingFrame
newButton.Label.Text = animationTitle
newButton:SetAttribute('Section', sectionName)
local animation = Instance.new('Animation')
animation.Parent = newButton.WorldModel
animation.AnimationId = 'rbxassetid://'..animationID
local avatar = nil
if Controller.UsePlayerCharacter then
-- Note, if the animation is R15 but your player character is R6, it wont work. Change your avatar type in Game settings.
local character = Player.Character or Player.CharacterAdded:Wait()
if character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
avatar = Assets.TemplateR15:Clone()
elseif character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
avatar = Assets.TemplateR6:Clone()
else
warn('Invalid player character type, could not load animation')
return
end
-- incase the template has shirt or pants, we have to remove them or else ApplyDescription wont work
local shirt, pants = avatar:FindFirstChildOfClass('Shirt'), avatar:FindFirstChild('Pants')
if shirt then
shirt:Destroy()
end
if pants then
pants:Destroy()
end
avatar.Parent = newButton.WorldModel -- we need to parent it for the ApplyDescription function to work
avatar.Humanoid:ApplyDescription(CharacterInformation)
else
if Controller.DefaultAvatarType == 'R15' then
avatar = Assets.TemplateR15:Clone()
elseif Controller.DefaultAvatarType == 'R6' then
avatar = Assets.TemplateR6:Clone()
else
-- must be either "R6" or "R15", R capital.
warn('Invalid AnimationType, only "R6" and "R15" are supported currently set to: ', Controller.DefaultAvatarType)
return
end
end
avatar.Parent = newButton.WorldModel
task.wait()
local loaded = avatar:WaitForChild('Humanoid').Animator:LoadAnimation(animation)
loaded.Looped = true
loaded.Priority = Enum.AnimationPriority.Action
loaded:Play()
local Camera = Instance.new("Camera")
Camera.Parent = newButton.WorldModel
Camera.Name = "CurrentCamera"
Camera.CFrame = CFrame.lookAt((avatar.HumanoidRootPart.CFrame * CFrame.new(0,0,-math.abs(Controller.ViewDistance))).p, avatar.HumanoidRootPart.Position)
newButton.CurrentCamera = Camera
newButton.TextButton.Activated:Connect(function()
Utility.SetRunningAnimation(newButton)
if Controller.HideUiOnSelect then
-- hide the ui
Controller.CloseGui()
end
end)
Utility.SetupNewButton(newButton)
table.insert(section, newButton)
end)
end
-- Controller.AddAnimation()
function Controller.AddAnimation(sectionName: string, animationTitle: string, animationID: number)
if type(animationID) ~= "number" then
if type(animationID) == 'string' then
if string.find(animationID, 'rbxassetid://') then
animationID = tonumber(string.split(animationID, '://')[2])
end
end
end
if not sectionName or not animationTitle or not animationID then
warn(('Controller.AddAnimation() Missing Argument %s'):format((not sectionName and '"sectionName"')) or (not animationTitle and '"animationTitle"') or '"animationID"')
return
end
AddAnimation(sectionName, animationTitle, animationID)
end
-- Controller.Refresh()
function Controller.Refresh()
for _, section in pairs(Sections) do
for _, button in pairs(section) do
button:Destroy()
end
end
table.clear(Sections)
for _, section in pairs(SectionsFolder:GetChildren()) do
local section_name = section.Name
AddSection(section_name)
code
for anim, id in pairs(require(section)) do
Controller.AddAnimation(section_name, anim, id)
task.wait()
end
end
end
-- Controller.ToggleState()
function Controller.ToggleState()
Controller.Enabled = not Controller.Enabled
if not Controller.Enabled then
tween(AnimationFrame, 'Position', Positions.Closed, 0.5)
Utility.DisableToggleButton()
else
tween(AnimationFrame, 'Position', Positions.Open, 0.5, Enum.EasingStyle.Back)
Utility.EnableToggleButton()
end
end
-- Controller.CloseGui()
function Controller.CloseGui()
tween(AnimationFrame, 'Position', Positions.Closed, 0.5)
Utility.DisableToggleButton()
end
-- Controller.OpenGui()
function Controller.OpenGui()
tween(AnimationFrame, 'Position', Positions.Open, 0.5, Enum.EasingStyle.Back)
Utility.EnableToggleButton()
end
-- Controller.DisableToggle()
function Controller.DisableToggle()
ToggleButton.Visible = false
Utility.DisableToggleButton()
end
-- Controller.EnableToggle()
function Controller.EnableToggle()
ToggleButton.Visible = true
end
-- last
Utility.SetupSectionButton(AnimationFrame.Sections.All, nil)
-- Apply global settings
if Controller.SectionsEnabled then
AnimationFrame.Sections.Visible = true
else
AnimationFrame.Sections.Visible = false
end
if Controller.KeyBind then
if typeof(Controller.KeyBind) ~= 'EnumItem' then
warn('Invalid keybind, must be an Enum.KeyCode')
else
game:GetService('UserInputService').InputBegan:Connect(function(inputObject, gameProcessedEvent)
if gameProcessedEvent then
return
end
if inputObject.KeyCode == Controller.KeyBind then
Controller.ToggleState()
end
end)
end
end
if Controller.ToggleButton then
Controller.EnableToggle()
else
Controller.DisableToggle()
end
if Controller.LoadOnRequire then
Controller.Refresh()
end
return Controller
Aqui está o código modificado que remove a função de usar os templates R15 e R6 e adiciona a função de organizar os emotes por ordem alfabética:
lua
-- Welcome to Animify V2
--[[
Version: 2.4
Documentation and API Link: https://devforum.roblox.com/t/2462029
Credits: Programmed by @4vials, designed by @ParadoxAssets
Contributors: @SaintImmor, @Bloxmaster998144
--]]
local Controller = setmetatable({}, {
__index = require(script:WaitForChild('Configuration'))
})
local Sections = {} -- cache to destroy when refreshing
-- UI Components
local AnimationGUI = script.Parent
local AnimationFrame = AnimationGUI:WaitForChild('MainFrame')
local ToggleButton = AnimationGUI:WaitForChild('toggle')
-- Dependencies
local Assets = script:WaitForChild('Assets')
local Player = game.Players.LocalPlayer
-- Animation Modules
local SectionsFolder = script:WaitForChild('Sections')
local Utility = require(script.Utility)
-- Controller variables
Controller.Frame = AnimationFrame
Controller.Enabled = false
-- Internal Variables
local PlayingAnimation = nil
-- Constants
local Positions = {
Open = UDim2.new(.5, 0, .5, 0),
Closed = UDim2.new(.5, 0, 1.5, 0)
}
-- Funcs
local tween = Utility.Tween
local function AddSection(sectionName: string)
if Sections[sectionName] then
warn(sectionName..' already exists')
return
end
local sectionButton = Assets.SectionButton:Clone()
sectionButton.Parent = AnimationFrame.Sections
sectionButton.Text = sectionName
Utility.SetupSectionButton(sectionButton, sectionName)
Sections[sectionName] = {sectionButton}
return Sections[sectionName]
end
local function AddAnimation(sectionName: string, animationTitle: string, animationID: number)
task.defer(function()
local section = Sections[sectionName] or AddSection(sectionName)
local newButton = Assets.AnimationButton:Clone()
newButton.Parent = AnimationFrame.Content.ScrollingFrame
newButton.Label.Text = animationTitle
newButton:SetAttribute('Section', sectionName)
newButton:SetAttribute('AnimationId', animationID)
-- Remove avatar preview code since templates are not used
-- You can add an image or some other representation if desired
newButton.TextButton.Activated:Connect(function()
Utility.SetRunningAnimation(newButton)
if Controller.HideUiOnSelect then
-- hide the ui
Controller.CloseGui()
end
end)
Utility.SetupNewButton(newButton)
table.insert(section, newButton)
end)
end
-- Controller.AddAnimation()
function Controller.AddAnimation(sectionName: string, animationTitle: string, animationID: number)
if type(animationID) ~= "number" then
if type(animationID) == 'string' then
if string.find(animationID, 'rbxassetid://') then
animationID = tonumber(string.split(animationID, '://')[2])
end
end
end
if not sectionName or not animationTitle or not animationID then
warn(('Controller.AddAnimation() Missing Argument %s'):format((not sectionName and '"sectionName"')) or (not animationTitle and '"animationTitle"') or '"animationID"')
return
end
AddAnimation(sectionName, animationTitle, animationID)
end
-- Controller.Refresh()
function Controller.Refresh()
for _, section in pairs(Sections) do
for _, button in pairs(section) do
button:Destroy()
end
end
table.clear(Sections)
for _, section in pairs(SectionsFolder:GetChildren()) do
local section_name = section.Name
AddSection(section_name)
local animations = require(section)
local anim_list = {}
for anim_name, id in pairs(animations) do
table.insert(anim_list, {name = anim_name, id = id})
end
-- Ordenar os emotes em ordem alfabética
table.sort(anim_list, function(a, b)
return a.name:lower() < b.name:lower()
end)
-- Adicionar as animações em ordem alfabética
for _, anim in ipairs(anim_list) do
Controller.AddAnimation(section_name, anim.name, anim.id)
task.wait()
end
end
end
-- Controller.ToggleState()
function Controller.ToggleState()
Controller.Enabled = not Controller.Enabled
if not Controller.Enabled then
tween(AnimationFrame, 'Position', Positions.Closed, 0.5)
Utility.DisableToggleButton()
else
tween(AnimationFrame, 'Position', Positions.Open, 0.5, Enum.EasingStyle.Back)
Utility.EnableToggleButton()
end
end
ToggleButton.TextButton.MouseButton1Down:Connect(Controller.ToggleState)
-- Controller.CloseGui()
function Controller.CloseGui()
tween(AnimationFrame, 'Position', Positions.Closed, 0.5)
Utility.DisableToggleButton()
end
-- Controller.OpenGui()
function Controller.OpenGui()
tween(AnimationFrame, 'Position', Positions.Open, 0.5, Enum.EasingStyle.Back)
Utility.EnableToggleButton()
end
-- Controller.DisableToggle()
function Controller.DisableToggle()
ToggleButton.Visible = false
Utility.DisableToggleButton()
end
-- Controller.EnableToggle()
function Controller.EnableToggle()
ToggleButton.Visible = true
end
-- last
Utility.SetupSectionButton(AnimationFrame.Sections.All, nil)
-- Apply global settings
if Controller.SectionsEnabled then
AnimationFrame.Sections.Visible = true
else
AnimationFrame.Sections.Visible = false
end
if Controller.KeyBind then
if typeof(Controller.KeyBind) ~= 'EnumItem' then
warn('Invalid keybind, must be an Enum.KeyCode')
else
game:GetService('UserInputService').InputBegan:Connect(function(inputObject, gameProcessedEvent)
if gameProcessedEvent then
return
end
if inputObject.KeyCode == Controller.KeyBind then
Controller.ToggleState()
end
end)
end
end
if Controller.ToggleButton then
Controller.EnableToggle()
else
Controller.DisableToggle()
end
if Controller.LoadOnRequire then
Controller.Refresh()
end
return Controller
Principais alterações:
Remoção dos Templates R15 e R6:
A função AddAnimation foi modificada para remover o código que utilizava os templates R15 e R6.
As referências aos templates Assets.TemplateR15 e Assets.TemplateR6 foram removidas.
O código relacionado ao avatar e à pré-visualização da animação foi removido, já que não estamos mais usando os templates.
Organização dos Emotes por Ordem Alfabética:
A função Controller.Refresh() foi atualizada para ordenar os emotes em ordem alfabética.
Utilizamos table.sort para ordenar a lista de animações com base no nome da animação (anim.name).
As animações são adicionadas em ordem alfabética após a ordenação.
Observações:
Como removemos o código que lida com os avatares, as pré-visualizações das animações não serão mais exibidas nos botões. Se você deseja adicionar alguma representação visual, como um ícone ou imagem, você pode modificar o código para incluir esse recurso.
Certifique-se de que o restante do script (como o módulo Utility e os recursos em Assets) suporte essas alterações. Pode ser necessário ajustar outras partes do código dependendo de como essas funções são implementadas.
Espero que isso atenda às suas necessidades! Se tiver alguma dúvida ou precisar de mais assistência, fique à vontade para perguntar.