I have made a recording and replay system for my game, which works great, by recording CFrames of the player’s bodyparts. However, when playing the recording back, the player character’s accesories welds do not work and are not attached to the character, as observed here:
I have read into WorldModels, and put one into my viewport, however it has sprung an entirely new issue as it seems to overwrite my script setting the model’s CFrames for the bodyparts, ending in the result that can be observed here:
How would I go about setting the accesories to the models in the viewport?
(Recording accesory CFrames is not an option)
code snippet of the replay loop:
for i=1,rec_Length do --play
if not active then break end
for name,t in pairs(self.Data) do
local model = t.Model --get char viewport model
local partnames = t.Parts --table with recorded part names
for _,partn:string in ipairs(partnames) do
if rec[name][partn][i] == nil then continue end
local part_cf = self:ConvertToCFrame(rec[name][partn][i])
--converting the recording data of the parts to cframes
model[partn].CFrame = part_cf
end
end
task.wait(1/40)
end
To my knowledge, Viewports don’t work on the server, and the Gui is running on the client, so AddAccessory isn’t going to work.
Your second link is a solution utilizing welds, and Viewports don’t run physics, so welds do not work.
Yet utilizing WorldModels do allow Physics to run in a viewport, in which case I wouldn’t need to worry nor would I need your provided solution for attaching accesories in the client. However, as i mentioned:
What I need is either information on a what could be causing the issue from using worldmodels, o̶r̶ ̶a̶ ̶m̶e̶t̶h̶o̶d̶ ̶o̶f̶ ̶a̶t̶t̶a̶c̶h̶i̶n̶g̶ ̶a̶c̶c̶e̶s̶s̶o̶r̶i̶e̶s̶ ̶w̶i̶t̶h̶o̶u̶t̶ ̶u̶s̶i̶n̶g̶ ̶w̶e̶l̶d̶s
The linked post has a method using CFrames but I would need information on each of the accesories that the playermodel has, for each of the players that are in a recording. and update it each frame, which I feel will complicate my already written system.
I have found the solution to my Issue! What was overwritting my character’s CFrames in the viewport were the model’s “Animator” and “Motor6D” objects that were created as a result of using PlayerService:CreateHumanoidModelFromDescription()
After deleting these when creating the model it is now working as intended.