Hey! I’ve created this ‘/sync User’ command for players to copy the animation of a in-game player! It works like this:
Code
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
Player.Chatted:Connect(function(Command)
local Split = string.split(Command, " ")
if Split[1] == "/sync" then
local Argument = Split[2]:lower()
local Target = nil
for x,y in pairs(game.Players:GetChildren()) do
local PlayerName = y.Name:lower()
local PlayerDisplayName = y.DisplayName:lower()
if PlayerName:find(Argument) or PlayerDisplayName:find(Argument) then
Target = y
local Humanoid = Character:WaitForChild("Humanoid")
local TargetHumanoid = Target.Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local TargetAnimator = TargetHumanoid:WaitForChild("Animator")
local AnimationTracks = TargetAnimator:GetPlayingAnimationTracks()
for x,y in pairs(AnimationTracks) do
local Track = Animator:LoadAnimation(y.Animation)
Track.Priority = Enum.AnimationPriority.Action
Track:Play()
Track.TimePosition = y.TimePosition
Track:AdjustSpeed(y.Speed)
end
end
end
end
end)
end)
end)
From here on, I’m wondering how I can stop the command user when they chat the words ‘/stopsync’.
I understand that AnimationTracks has a :Stop() command, but I tried this and it didn’t seem to do me justice.
Any help is appreciated!! ![]()