- What do you want to achieve?
A Full on Working Sync Command that supports both AnimationTrack changing and ability to sync one person onto another designated person for any dance they are playing.
- What is the issue?
ATM of version 1.0 of the SYNC command. You are able to sync to a player dance but, if a player changes their animationId or animation. It will stop syncing the player with the right dance. So I need to add a AnimationTrack:Change or animationId:Change and basically then put that as the dance.
- What solutions have you tried so far?
There hasn’t been any solutions atm, Im not familiar with animations at all. So if anyone can lead me in the right direction it would be greatly appreciated!
Heres the working VERISON 1.0 Source code -
--[[
@author TwinPlayzDev_YT
@credit Neutron_Flow (helped with animator parts)
@since 2/15/2021
This script will let players sync animations with other players.
Place this script in ServerScriptService.
--]]
--[ SERVICES ]--
local Players = game:GetService("Players")
--[ MAIN LOCALS ]--
local syncthing = "/sync ([%w_]+)" --this is a string pattern that should match any player username
local leavesync = "/leavesync" -- string for leaving the sync
--[ FUNCTIONS ]--
game.Players.PlayerAdded:Connect(function(localplr)
localplr.Chatted:Connect(function(msg)
--[{ JOINSYNC }]--
local subjectName = msg:match(syncthing) -- checking to see if it matches text
if subjectName then
local subject = game.Players:FindFirstChild(subjectName)
if subject then
-- play animation
local humanoid = localplr.Character:WaitForChild("Humanoid") -- player humanoid
local humanoid2 = subject.Character:WaitForChild("Humanoid") -- subject humanoid
local animator = humanoid:WaitForChild("Animator") -- player animator
local animator2 = humanoid2:WaitForChild("Animator") -- subject animator
local AnimationTracks = animator2:GetPlayingAnimationTracks() -- subject animation tracks
for _, v in pairs(AnimationTracks) do
local track = animator:LoadAnimation(v.Animation) -- requires an animation object
track.Priority = Enum.AnimationPriority.Action
track:Play()
track.TimePosition = v.TimePosition
track:AdjustSpeed(v.Speed)
end
end
end
--[{ LEAVESYNC }]--
local leaveName = msg:match(leavesync) -- checking to see if it matches text
if leaveName then
-- stop animation
local humanoid = localplr.Character:WaitForChild("Humanoid") -- player humanoid
local animator = humanoid:WaitForChild("Animator") -- player animator
local AnimationTracks = animator:GetPlayingAnimationTracks() -- player animation tracks
for _,v in pairs(AnimationTracks) do
v:Stop()
end
end
end)
end)