For my new game I want to make the characters(R15) change into the skeleton package when they get struck by lightning, but I am unsure how I would do that with R15 characters since they don’t use character meshes like R6 characters do. Thank you!
1 Like
local players = game:GetService("Players")
local assetService = game:GetService("AssetService")
local insertService = game:GetService("InsertService")
local function makeSkeleton(character)
local humanoid = character:WaitForChild("Humanoid")
local success, result = pcall(function()
return assetService:GetBundleDetailsAsync(295)
end)
if success then
if result then
for _, bundleItem in ipairs(result.Items) do
if bundleItem.Type == "Asset" then
local success2, result2 = pcall(function()
return insertService:LoadAsset(bundleItem.Id)
end)
if success2 then
if result2 then
if humanoid.RigType == Enum.HumanoidRigType.R6 then
local r6Folder = result2:FindFirstChild("R6")
if r6Folder then
local bundleMesh = r6Folder:FindFirstChildOfClass("CharacterMesh")
if bundleMesh then
for _, characterMesh in ipairs(character:GetChildren()) do
if characterMesh:IsA("CharacterMesh") then
if characterMesh.BodyPart == bundleMesh.BodyPart then
characterMesh:Destroy()
end
end
end
bundleMesh.Parent = character
end
end
elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
local r15Folder = result2:FindFirstChild("R15")
if r15Folder then
for _, bundlePart in ipairs(r15Folder:GetChildren()) do
if bundlePart:IsA("BasePart") then
humanoid:ReplaceBodyPartR15(Enum.BodyPartR15[bundlePart.Name], bundlePart)
end
end
end
end
end
else
warn(result2)
end
end
end
end
else
warn(result)
end
end
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if not player:HasAppearanceLoaded() then
player.CharacterAppearanceLoaded:Wait()
end
makeSkeleton(character)
end)
end)
Well I just wrote this which works for both avatar types (R6 and R15).
2 Likes