So I basicly want to clone my character and place it in the same position and with the same rig as a dummy.
I have never made this before so I tried a simple solution that clearly didn’t work and then I tried to look up on the internet but i fount absolutely nothing.
These are two samples of code that I have tried:
WHAT I TOUGHT IT CAN BE
local insertService = game:GetService(“InsertService”)
game.Players.PlayerAdded:Connect(function(plr)
local Id = plr.UserId
local Model = insertService:LoadAsset(Id)
Model.Parent = workspace
end)
WHAT I HAVE FOUDN IN ANOTHER SCRIPT
if PlayAnimationInRig.currentId == userId then return end
PlayAnimationInRig.currentId = userId
PlayAnimationInRig.StopAnimationTrack()
PlayAnimationInRig.rig:Destroy()
PlayAnimationInRig.rig = PlayAnimationInRig.rigCopy:Clone()
PlayAnimationInRig.rig.Parent = script.Parent
local humanoidDescription = Players:GetHumanoidDescriptionFromUserId(userId)
PlayAnimationInRig.humanoid:ApplyDescriptionReset(humanoidDescription)
local tagClone = PlayAnimationInRig.tag:Clone()
tagClone.Enabled = true
tagClone.Parent = PlayAnimationInRig.rig.Head
PlayAnimationInRig.humanoid.DisplayName =
Players:GetNameFromUserIdAsync(userId)
sorry for bad english :]
you need to do a loop through all descendant instances of the model you want to clone and make sure that “Archivable” = true
So I tried your solution and I think it will work but I am getting this err:
attempt to index nil with getDescendants
here is the code:
game.Players.PlayerAdded:Connect(function(plr)
local playerModel = plr.Character:GetDescendants()
local dummy = workspace:WaitForChild(“Dummy”):GetDescendants()
for i, v in ipairs(playerModel) do
print(v)
dummy[v] = playerModel[v]
end
end)
The moment the player joins the game, their character wont be loaded. You could just add a repeat loop that waits until the the character is not nil.
repeat
task.wait()
until plr.Character ~= nil
Or even better- you can use player.CharacterAdded:Wait() if you don’t want a random repeat loop.
I don’t get the err. anymore but the model doesn’t change, it is still in its basic form
this is the code:
game.Players.PlayerAdded:Connect(function(plr)
repeat
task.wait()
until plr.Character ~= nil
local playerModel = plr.Character:GetDescendants()
local dummy = workspace:WaitForChild("Dummy"):GetDescendants()
for i, v in ipairs(dummy) do
print(v)
dummy[v] = playerModel[v]
end
end)
Are you trying to make it so the dummy looks like the character?
yes, and everything looks fine but the dummy doesn’t change at all
dummy.Humanoid:ApplyDescription(game:GetService(“Players”):GetHumanoidDescriptionFromUserId(plr.UserId))
^ This should be your entire script:
game:GetService("Players").PlayerAdded:Connect(function(plr)
dummy.Humanoid:ApplyDescription(game:GetService(“Players”):GetHumanoidDescriptionFromUserId(plr.UserId))
end)
It is working, thank you, but i do still have a problem, the character is in the basic state of staying on his foots but I want it as the original dummy, which is sitting
game:GetService("Players").PlayerAdded:Connect(function(plr)
dummy.Humanoid:ApplyDescription(game:GetService(“Players”):GetHumanoidDescriptionFromUserId(plr.UserId))
plr.CharacterAdded:Wait(c)
c:WaitForChild("Humanoid")
c.Humanoid.Sit = true
end)
it is still on its foots
this is the code:
local dummy = workspace:WaitForChild(“Dummy”)
game:GetService(“Players”).PlayerAdded:Connect(function(plr)
dummy.Humanoid:ApplyDescription(game:GetService(“Players”):GetHumanoidDescriptionFromUserId(plr.UserId))
local char = plr.CharacterAdded:Wait(char)
char:WaitForChild(“Humanoid”)
char.Humanoid.Sit = true
end)
local dummy = workspace:WaitForChild(“Dummy”)
game:GetService(“Players”).PlayerAdded:Connect(function(plr)
dummy.Humanoid:ApplyDescription(game:GetService(“Players”):GetHumanoidDescriptionFromUserId(plr.UserId))
local char = plr.Character
plr.CharacterAdded:Wait(char)
char:WaitForChild(“Humanoid”)
char.Humanoid.JumpHeight = 0 -- if you are using jumppower, do char.Humanoid.JumpPower = 0
char.Humanoid.Sit = true
end)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
character.Archivable = true
local CloneChar = character:Clone()
CloneChar.Parent = workspace
character.Archivable = false
end)
end)
still on its foots.
this is the code:
local dummy = workspace:WaitForChild(“Dummy”)
game:GetService(“Players”).PlayerAdded:Connect(function(plr)
dummy.Humanoid:ApplyDescription(game:GetService(“Players”):GetHumanoidDescriptionFromUserId(plr.UserId))
local char = plr:WaitForChild(“Character”)
plr.CharacterAdded:Wait(char)
char:WaitForChild(“Humanoi”)
char.Humanoid.JumpPower = 0
char.Humanoid.Sit = true
end)
I tried as well with jumpHeight
Well then it’s on you to figure out, I gotta do other stuff rn.
You are right, thank you for your help because you still kinda solved my problem
So i just made an animation that will activate when the player joins the game. So the sit problem is fixed