This script took more time to make than I care to disclose. It will replace your character with the model while preserving the scripts and the position of your character.
It’s definitely not the most sophisticated thing in the world but I thought i’d share it just because it’s nice to have the general idea.
local function transform(char,model)
local model=model:Clone()
model:SetPrimaryPartCFrame(char.PrimaryPart.CFrame+Vector3.new(0,model:GetExtentsSize().Y,0))
local h=char.Humanoid
local function unkill()
h:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
end
for i,v in pairs(h:GetPlayingAnimationTracks()) do
v:Stop()
end
h.Parent=game.ReplicatedStorage
unkill()
for i,v in pairs(char:GetChildren()) do
if v.Name~="Humanoid" and not v:IsA("Script") and not v:IsA("LocalScript") then
v:Destroy()
end
end
local hipheight=model.Humanoid.HipHeight
local primary=model.PrimaryPart
for i,v in pairs(model:GetChildren()) do
if v.Name~="Humanoid" then
v.Parent=char
end
end
-- synchronize.
model:Destroy()
char.PrimaryPart=char.HumanoidRootPart
h.HipHeight=hipheight
h.Parent=char
char.PrimaryPart=char.HumanoidRootPart
h.HipHeight=hipheight
local plr=game.Players:GetPlayerFromCharacter(char)
if plr then -- thanks roblox.
game.ReplicatedStorage.HipHeight:FireClient(plr,hipheight)
end
end
transform(game.Players["you"].Character,workspace.Dummy)
-- NOTE: if you are transforming a player into a model, you must also prevent their state from changing to dead on the client.
--[[ This can be accomplished in a makeshift way most by firing some sort of remote function to the player
when receiving the remote (on client), run:
spawn(function()
for i=1,120 do
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead,false)
game:GetService("RunService").Heartbeat:wait()
end
end)
wrap it in spawn so it doesnt delay transformation.
--]]
I made this script based on this post. Are there any methods of cleanly swapping character models from default rigs to custom character constructs? - #12 by PeZsmistic
Note: this script prevents characters from dying. I don’t fully understand humanoid states so keep in mind that if you ever use this script it’ll need fixing in that area