I’m trying to make an animation game where you can choose the avatars for the animation but I can’t find a way to use ApplyDescription() without it returning an error such as “Invalid argument: expected ‘HumanoidDescription’, got Instance”.
Local script in StarterGui:
script.Parent.MouseButton1Click:Connect(function()
local input = script.Parent.Parent.InputBox
local animationsFolder = game.ReplicatedStorage.Animations
local dummy = workspace.R6
local applyDescRemote = game.ReplicatedStorage.Events.applyDescRemote
local humanoid = dummy.Humanoid
-- Get the username from the input box
local username = input.Text
-- Use the Roblox API to get the userId from the username
local userId = game.Players:GetUserIdFromNameAsync(username)
if userId then
local appearance = game.Players:GetHumanoidDescriptionFromUserId(userId)
print('Attempting to load animation on rig for user '..username)
applyDescRemote:FireServer(appearance)
if humanoid then
-- Assuming the animation is stored in the Animations folder
local animation = animationsFolder:FindFirstChild('Boogie Down') -- replace 'AnimationName' with the name of your animation
if animation then
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack.Looped = false -- Make sure the animation does not loop
animationTrack:Play()
else
print('Animation not found')
end
else
print('Humanoid not found in the character')
end
else
print('User not found')
end
end)
Normal script in ServerScriptService:
game.ReplicatedStorage.Events.applyDescRemote.OnServerEvent:Connect(function(appearance)
if typeof(appearance) == "Instance" and appearance:IsA("HumanoidDescription") then
local dummy = game.Workspace.R6
local humanoid = dummy.Humanoid
humanoid:ApplyDescription(appearance)
else
warn("Invalid argument: expected 'HumanoidDescription', got " .. typeof(appearance))
end
end)