Attempt to index boolean with 'HumanoidRootPart'

Hello Scripters!

I had been Making a project about becoming a ghost when dead

And this error shows up

Heres the part that shows up the error

			local character = v.Character and not clone
			local velocity = character.HumanoidRootPart

It’s because of the not clone bit. The code is defining character as OBJECT and not BOOL, which results in the final result being a boolean.

What are you trying to achieve with it? You should be using the not clone in an if statement to handle it seperately.

yeah if you need there to be a definer that says its not a clone, why dont you just identify clones and the players differently, or would there be a problem for that?

if i remove the not clone then it would just push the clone off. how could i fix it

Without additional information we can’t provide further assistance.
Without extra info, the only advice i can give is to enclose the whole thing in if not clone then (and remove the not clone bit from the character definition)

could we get some context, what do you mean by it pushes the clone off? can you give screenshots or a video?

i can just show you the script

for i, v in pairs(game.Players:GetPlayers()) do
	local char = v.Character
	char.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
		if char.Humanoid.Health < 1 then
			char.Humanoid.MaxHealth = math.huge
			char.Humanoid.Health = char.Humanoid.MaxHealth
			char.Humanoid.WalkSpeed = 30
			char.Archivable = true
			local clone = char:Clone()
			clone.Parent = workspace
			clone:PivotTo(char.PrimaryPart.CFrame)
			for key, value in pairs(char:GetDescendants()) do
				if value:IsA("BasePart") and value.Name ~= "HumanoidRootPart" then
					value.Transparency = 0.5
				end
			end
			local character = v.Character
			local velocity = character.HumanoidRootPart
			velocity.AssemblyLinearVelocity = char.PrimaryPart.CFrame.LookVector * 7000
			for iv, vi in pairs(clone:GetDescendants()) do
				if vi:IsA("Motor6D") then
					local humanoid = vi.Parent.Parent:FindFirstChildOfClass("Humanoid")
					local players = game.Players:GetPlayerFromCharacter(vi.Parent.Parent)
					if players then
						
					else
						humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
						humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
					end
					humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
					humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
					vi.Enabled = false
					vi.Parent.Parent.Humanoid.PlatformStand = true
					humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
					humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
					local a0 = Instance.new("Attachment")
					local a1 = Instance.new("Attachment")
					a0.Parent = vi.Part0
					a1.Parent = vi.Part1
					local bsc = Instance.new("BallSocketConstraint")
					bsc.Parent = vi.Parent
					bsc.Attachment0 = a0
					bsc.Attachment1 = a1
					a0.CFrame = vi.C0
					a1.CFrame = vi.C1
					bsc.LimitsEnabled = true
					bsc.TwistLimitsEnabled = true
					vi:Destroy()
				end
			end
			task.wait(0.1)
			velocity.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
		end
	end)
end

uhh, ok, so i cant see the problem right now, the code does need a little optimization but lemme look around to see why the clone could be falling off, which im guessing just means he like takes no velocity and just ragdolls down right?

try this code and lmk if it works

for i, v in pairs(game.Players:GetPlayers()) do
	local char = v.Character
	if char and char:FindFirstChild("Humanoid") then
		local humanoid = char.Humanoid
		
		local healthChangedConnection
		healthChangedConnection = humanoid:GetPropertyChangedSignal("Health"):Connect(function()
			if humanoid.Health < 1 then
				humanoid.MaxHealth = math.huge
				humanoid.Health = humanoid.MaxHealth
				humanoid.WalkSpeed = 30
				char.Archivable = true
				
				local clone = char:Clone()
				clone.Parent = workspace
				clone:PivotTo(char.PrimaryPart.CFrame)
				
				for _, value in pairs(char:GetDescendants()) do
					if value:IsA("BasePart") and value.Name ~= "HumanoidRootPart" then
						value.Transparency = 0.5
					end
				end
				
				local velocity = char.HumanoidRootPart
				velocity.AssemblyLinearVelocity = char.PrimaryPart.CFrame.LookVector * 7000
				
				for _, vi in pairs(clone:GetDescendants()) do
					if vi:IsA("Motor6D") then
						local Chumanoid : Humanoid = clone:FindFirstChild("Humanoid")
						if not Chumanoid then continue end
						
						Chumanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
						Chumanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
						vi.Enabled = false
						clone.Humanoid.PlatformStand = true
						
						local a0 = Instance.new("Attachment")
						local a1 = Instance.new("Attachment")
						a0.Parent = vi.Part0
						a1.Parent = vi.Part1
						local bsc = Instance.new("BallSocketConstraint")
						bsc.Parent = vi.Parent
						bsc.Attachment0 = a0
						bsc.Attachment1 = a1
						a0.CFrame = vi.C0
						a1.CFrame = vi.C1
						bsc.LimitsEnabled = true
						bsc.TwistLimitsEnabled = true
						vi:Destroy()
					end
				end
				
				task.wait(0.1)
				velocity.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
			
				healthChangedConnection:Disconnect()
			end
		end)
	end
end

it still didnt work and pushes the clone instead

bruh i dont have any idea whats happening

This line is wrong. It outputs true if the character exists and the clone doesn’t and false otherwise, which isn’t a character.

local character = v.Character and not clone

What do you want this line to do? Do you want it to do the character or the clone if no character exists? That would be:

local character = v.Character or clone
-- Or with the newer syntax:
local character = v.Character if v.Character else clone

The “and” is turning the character variable into a boolean.

thats quite the opposite of what i wanted
what i wanted here is to get the character but since the character is cloned it just gets the clone
thats not what i wanted
unless maybe the or just returns false