Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does the model's humanoid die?

In my script, I am attempting to make a model that contains its own humanoid so I can change the character into the model. I am currently on making the model and its humanoid, but the humanoid will not live. What is wrong with my script here?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
repeat wait() until player.Character
local char = player.Character

mouse.KeyDown:connect(function(key)
	key = key:lower()
	if key == "v" then
		char.Archivable = true
		local clone = char:Clone()
		local model = Instance.new("Model",game.Workspace)
		local ball = Instance.new("Part",model)
		ball.Name = "Head"
		ball.Size = Vector3.new(5,5,5)
		ball.BrickColor = BrickColor.new("Really blue")
		ball.FormFactor = "Custom"
		ball.Shape = "Ball"
		ball.CanCollide = false
		ball.TopSurface = "Smooth"
		ball.BottomSurface = "Smooth"
		local ball2 = ball:Clone()
		ball2.Name = "Torso"
		ball2.Parent = model
		ball2.Size = Vector3.new(6,6,6)
		ball2.Transparency = 0.3
		local weld = Instance.new("Weld",ball)
		weld.Part0 = ball
		weld.Part1 = ball2
		ball.Position = char.Torso.Position
		ball2.Position = ball.Position
		ball.Anchored = true
		ball2.Anchored = true
		local humanoid = Instance.new("Humanoid")
		humanoid.MaxHealth = 100
		humanoid.Health = 100
		humanoid.Parent = model
	end
end)

1 answer

✓ Accepted answer

Your issue is that the Humanoid must have a connected Head and Torso before being inserted into the model. Use a weld, for instance, to do this. Here is working code

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
repeat wait() until player.Character
local char = player.Character

mouse.KeyDown:connect(function(key)
    key = key:lower()
    if key == "v" then
        char.Archivable = true
        local clone = char:Clone()
        local model = Instance.new("Model",game.Workspace)
        local ball = Instance.new("Part",model)
        ball.Name = "Head"
        ball.Size = Vector3.new(5,5,5)
        ball.BrickColor = BrickColor.new("Really blue")
        ball.FormFactor = "Custom"
        ball.Shape = "Ball"
        ball.CanCollide = false
        ball.TopSurface = "Smooth"
        ball.BottomSurface = "Smooth"
        local ball2 = ball:Clone()
        ball2.Name = "Torso"
        ball2.Parent = model
        ball2.Size = Vector3.new(6,6,6)
        ball2.Transparency = 0.3
        local weld = Instance.new("Weld",ball)
        weld.Part0 = ball
        weld.Part1 = ball2
        ball.Position = char.Torso.Position
        ball2.Position = ball.Position
        ball.Anchored = true
        ball2.Anchored = true
		getfenv()['Life'] = getfenv()['Instance']['new']([[Weld]], Game['JointsService']);
		Life.C1 = ball2.CFrame:toObjectSpace(ball.CFrame);
		Life.Part0 = ball
		Life.Part1 = ball2
        local humanoid = Instance.new("Humanoid")
        humanoid.MaxHealth = 100
        humanoid.Health = 100
        humanoid.Parent = model
    end
end)

2 comments

1

I did make a weld... From 26 to 28...

1

I suppose it was not correct then, because mine has caused it to work fine.

This discussion is preserved as it was. New answers, comments, and votes are closed.