So I’ve noticed that you can’t animate character models within a ViewPortFrame.
Doing some research, I found a post about updating Motor6D with Transform.
My problem is that my script doesn’t seem to work.
c = Character model in ViewPortFrame proxyAnim = Table containing actual player character’s Motor6 instances
repeat
game:GetService('RunService').RenderStepped:Wait()
for _,v in pairs(proxyAnim) do
c:FindFirstChild(v.Name,true).Transform = v.Transform
end
until dead
I’ve printed both values and it outputs that it’s updating, but the character model in the ViewPortFrame isn’t changing nor are its Motor6 instances. But even changing them manually doesn’t seem to do anything in Studio. Does this no longer work or am I doing something wrong?
If this is no longer possible, I plan on simply updating all of the BasePart CFrames.
Did you attempt to play any animations on the character clone? You can’t just copy the character and hope that the duplicate automatically plays animations matching the actual character.
The gif below was set up using a ViewPortFrame and a WorldModel.
I copied the idle animation from my character in Studio and loaded that directly into the clone’s humanoid and played it. Nothing seems to have happened.
function ang(x,y,z) return CFrame.Angles(math.rad(x),math.rad(y),math.rad(z)) end
local P = game:GetService('Players')
local p = P.LocalPlayer
local port = script.Parent:WaitForChild('Port')
local cam = Instance.new('Camera',script)
local anim = script:WaitForChild('Animation1')
port.CurrentCamera = cam
if not p.Character then p.CharacterAdded:Wait() end
p.Character:WaitForChild('HumanoidRootPart')
wait(1)
local c = Instance.new('Model')
for _,v in pairs(p.Character:GetChildren()) do
if not v:IsA('BaseScript') then
v:Clone().Parent = c
end
end
c.Parent = port:WaitForChild('World')
cam.CFrame = c.HumanoidRootPart.CFrame*ang(0,180,0)*CFrame.new(0,0,5)
local idle = c.Humanoid:LoadAnimation(anim)
idle.Looped = true
idle:Play()
(I know there are some parts that can be improved, but I’m just doing this for testing right now.)
You’re cloning the parts of the character and putting them in a new model - there’s no humanoid to load an animation to. There also wouldn’t be any joints. (Edit: Misread “BaseScript” as “BasePart”)
Set the Archivable property of the actual character to true (it’s false by default) and then you can just call :Clone() on the player’s character.
Hey, I tried this solution but it doesn’t work for me!
I’m using a module and a remote event to make this work.
I’m essentially using the exact same code as you and all the animation checks pass, am I doing something wrong?
-- Everything else is cut to save space
function emoteV.Get(emoteName)
local oldNPC = template:WaitForChild("R6"):WaitForChild("NPC")
local newTemp = template:Clone()
local hum = oldNPC:FindFirstChild("Humanoid")
local animator = hum:FindFirstChild("Animator")
if emoteFolder:FindFirstChild(emoteName) then
if newTemp and oldNPC and hum and animator then
local emote = emoteFolder:FindFirstChild(emoteName)
oldNPC.Parent = workspace
local emoteTrack = animator:LoadAnimation(emote)
oldNPC.Parent = newTemp
emoteTrack.Looped = true
emoteTrack:Play()
return newTemp
end
end
end
Gui Hierachy;
Gui Local Code for getting viewport (everything else is irrelevant);
local function setupEmotes()
for i, frame in emoteFolder:GetChildren() do
if frame.EmoteName.Text then
if not frame:FindFirstChild("tempViewport") then
local viewport = viewportMod.Get(frame.EmoteName.Text)
viewport.Size = goodSize
viewport.Position = goodPos
viewport.Parent = frame
end
end
end
end
I’m a bit confused on what you’re doing here with the oldNPC and newTemp thing. It looks like you’re cloning the old template, then moving the old NPC to the the cloned temp, which already has an NPC as well? I’m also just confused on the purpose of doing all of this in the first place.