Hi. How could I make two humanoids be in the same animation. Is it even possible?
What do you want to achieve? Two humanoids be in the same animation.
What is the issue? The separate animations don’t play at the time needed.
What solutions have you tried so far? Tried PlayerAdded event. Didn’t work.
The code below ran fine at first, and now it doesn’t work. I think it’s because it’s in a LocalScript now, as I transitioned this code from a regular Script to a LocalScript.
local StageEvent = game.Workspace["Camera Field"].Stage:WaitForChild("StageEvent")
Playing = nil
Knight = nil
Barbarian = nil
Ally = nil
Enemy = nil
AllyAnimator = nil
EnemyAnimator = nil
StageEvent.OnClientEvent:Connect(function(Field)
while wait() do
Knight = Field:FindFirstChild("Knight Staged (RIGHT)")
Barbarian = Field:FindFirstChild("Barbarian Staged (RIGHT)")
if Knight ~= nil and Barbarian ~= nil and Knight:FindFirstChild("Humanoid") and Barbarian:FindFirstChild("HumanoidE") then
Ally = Knight.Humanoid
Enemy = Barbarian.HumanoidE
if Ally ~= nil and Enemy ~= nil and Ally:FindFirstChild("Animator") and Enemy:FindFirstChild("Animator") then
AllyAnimator = Ally.Animator
EnemyAnimator = Enemy.Animator
local AllyAnim = AllyAnimator:LoadAnimation(Knight.Animation)
local BarbarianAnim = EnemyAnimator:LoadAnimation(Barbarian.Animation)
AllyAnim.Priority = Enum.AnimationPriority.Action4
BarbarianAnim.Priority = Enum.AnimationPriority.Action4
BarbarianAnim:Play()
task.wait(3.18)
AllyAnim:Play()
task.wait(8.23)
Barbarian.Fade.Disabled = false
end
end
end
end)
The code above is supposed to run once the Player has loaded in, and no longer sees the Automatic Roblox Loading Screen. However, I don’t think it’ll work that way. I don’t see any Roblox Cores that mention the loading screen. Which is why I’d like to know if it’s possible to make two humanoids be in the same animation. Can they? If not, then how can I make the animations play once the Roblox Loading Screen is gone?
You could use ContentProvider:PreloadAsync() to check when every in-game asset is loaded, if that suffices.
Something like this:
local ctp = game:GetService("ContentProvider")
local assets = game:GetDescendants()
for i = 1, #assets do
local asset = assets[i]
ctp:PreloadAsync({asset}) --Yields until the asset has finished loading
end
--Whatever you want to happen after all assets have finished loading
NOTE: For scripts like these, it is suggested you put them under ReplicatedFirst, so it loads before anything else does.
Well, I can try getting some footage of it. And I’ve already explained it. The problem is that the animation plays too early for the Ally. The enemy animation plays on time, but the Ally’s does not.
Here’s what I’m trying to do. When a player joins the game, the following animations that you saw in the previous code block are supposed to play. However, because the player may load in the game too late, the animations either play too early, or have already finished. Which I do not want. It needs to be when the player loads in properly, the animations play on time. I changed the code a little bit. The new code works fine, but it’s in a LocalScript now, and the LocalScript is currently parented to ReplicatedFirst, and the Knight also doesn’t walk to the specified part. I’m not sure if that’s why the Knight doesn’t walk to the specified part in the code block or not, because the code is now in a LocalScript.
i don’t think PreloadAsync preloads animations, but okay
@Wizzthepixelcat try getting the animators in the humanoids outside of the event instead of inside, and load the animations onto them, it’s up to you how to implement this as i don’t explicitly know what your code is meant to do
if you can figure it out though this is probably guaranteed to fix your issue
Keep in mind that anything in ReplicatedFirst will be, well… replicated first.
Some things to note while scripting anything time sensitive as the player is joining is when content is loaded, when it’s visible, etc.
Make sure you are using ContentProvider:PreloadAsync() correctly and that you are preloading all content BEFORE running your code. You can use the code I provided in this post.
PreloadAsync should not break any scripts on the client assuming you’re using it correctly and before running the important code.
To clear any possible confusion, here’s the order of which you would structure your code, should you use my method.
Preload content with ContentProvider:PreloadAsync().
Define and load any animations to the specified animator outside and before the event. (like @Ar_iellle stated)
Define the function and connect the event, once everything else is finished.
Make sure to not call the event until all content is loaded!!
I unfortunately had to change everything, as nothing listed here actually solved my issue. Since you’re the first person that even acknowledged this, I’m going to list it as you have solved my issue.