So recently , I’ve been coming along a sort of problem with animations and dances. I’ve been working on getting a /sync and /leavesync command like the game Animations:MoCap.
The problem now when you normally are syncing to a player you want it to match the exact and I mean exact time position of the subjects dance animations.
What I have so far :
--[[
@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:Play()
track.TimePosition = v.TimePosition
end
print("dance played")
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
print("dance stopped")
end
end)
end)
What part i’m looking at -
for _, v in pairs(AnimationTracks) do
local track = animator:LoadAnimation(v.Animation) -- requires an animation object
track:Play()
track.TimePosition = v.TimePosition
end
Ive been doing some research and getting help from a friend @Neutron_Flow Credits to him for helping me out.
He told me that its going to be harder to now try and get the time position because of this -
This item is not replicated across Roblox’s server/client boundary.
If anyone has any idea how I can go around this, or maybe just maybe easily fix this. This script is in ServerScriptService and is just grabbing the humanoids animations and playing them the same way as others. But the .TimePosition is the problem right now.