HumanoidRootPart is not a valid member of model ("Player")

Hey all,

So I am making a game with monsters. Monster #1 is a monster that will kill you if you touch it. It will also destroy your baseparts (humanoidrootpart, torso, legs, arms).
Monster #2 will take you to another dimension if you type something in the chat. Problem is, if monster #1 destroys all your baseparts including humanoidrootpart, Monster #2 cannot teleport you to the dimension, ending with the error.
I NEED it to be humanoidrootpart, not anything else. I have tried making “if - then” statements but they would never ever work. I have also looked on several forums.

So I basically want monster #2 to detect whether there is still a humanoidrootpart in a player or not. I just cant seem to find out what to do!

Here are the scripts.
Monster #1:

local SCP = script.Parent.Parent
local Killsound = script.Parent.Kill
local Killsound2 = script.Parent.Kill2
local Killsound3 = script.Parent.Kill3
local Laugh = script.Parent.Laugh
local Screamer = script.Parent.Screamer
local TargetBrick = script.Parent.Parent.TargetBrick
local Particle = script.Parent.Parent.ParticleBlock.ParticleEmitter
local Killing = script.Parent.Killing

local Sigh1 = SCP.Head.Sigh1
local Sigh2 = SCP.Head.Sigh2
local Sigh3 = SCP.Head.Sigh3
local Sigh4 = SCP.Head.Sigh4
local Sigh5 = SCP.Head.Sigh5
local Sigh6 = SCP.Head.Sigh6
local Sigh7 = SCP.Head.Sigh7
local Sigh8 = SCP.Head.Sigh8

--Badge
local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")
local IDToAward = 2140861943


local Attacking = false

function onTouch(part) 
	local humanoid = part.Parent:FindFirstChild("Humanoid") 
	if (humanoid ~= nil) and humanoid.Health > 0 and Attacking == false then
		Attacking = true
		Killing.Value = true
		local Player = Players:GetPlayerFromCharacter(humanoid.Parent)
		if Player and not BadgeService:UserHasBadgeAsync(Player.UserId, IDToAward) then
			BadgeService:AwardBadge(Player.UserId, IDToAward)
			print("Awarded ENCLOSED Badge to victim")
		else if BadgeService:UserHasBadgeAsync(Player.UserId, IDToAward) then
				print("Not a player or already has the badge")
			end
		end
		local KillSoundRandomizer = math.random(1,3)
		if KillSoundRandomizer == 1 then
			SCP017.WalkSpeed = 0
			Killsound:Play()
			wait(.3)
			Screamer:Play()
			humanoid.Health = 0
			humanoid.BreakJointsOnDeath = false
			wait(.1)
			Particle.Size = NumberSequence.new(2,3)
			wait(.1)
			humanoid.Parent.HumanoidRootPart.CFrame = SCP017.Parent.HumanoidRootPart.CFrame
			Particle.Size = NumberSequence.new(3,4)
			wait(.1)
			Particle.Size = NumberSequence.new(4,5)
			wait(.1)
			Particle.Size = NumberSequence.new(5,6)
			wait(.1)
			Particle.Size = NumberSequence.new(6,7)
				if humanoid then -- if Humanoid Exists
					for _,i in humanoid.Parent:GetDescendants() do -- iterates through Character
					if not i:IsA("Humanoid")  then -- if Instances arent a Humanoid
							i:Destroy() -- Destroys Instances
							end
						end
					end
			wait(7)
			local Randomizer = math.random(1,8)
			if Randomizer == 1 then
				Sigh1:Resume()
				print("017 Taunt #1")
			elseif Randomizer == 2 then
				Sigh2:Resume()
				print("017 Taunt #2")
			elseif Randomizer == 3 then
				Sigh3:Resume()
				print("017 Taunt #3")
			elseif Randomizer == 4 then
				Sigh4:Resume()
				print("017 Taunt #4")
			elseif Randomizer == 5 then
				Sigh5:Resume()
				print("017 Taunt #5")
			elseif Randomizer == 6 then
				Sigh6:Resume()
				print("017 Taunt #6")
			elseif Randomizer == 7 then
				Sigh7:Resume()
				print("017 Taunt #7")
			elseif Randomizer == 8 then
				Sigh8:Resume()
				print("017 Taunt #8")
			end
			wait(2)
			Particle.Size = NumberSequence.new(6,6)
			wait(.01)
			Particle.Size = NumberSequence.new(5,5)
			wait(.01)
			Particle.Size = NumberSequence.new(4,4)
			wait(.01)
			Particle.Size = NumberSequence.new(3,3)
			wait(.01)
			Particle.Size = NumberSequence.new(2,2)
			wait(.01)
			SCP017.WalkSpeed = 50
		end
		if KillSoundRandomizer == 2 then
			SCP017.WalkSpeed = 0
			Killsound2:Play()
			Screamer:Play()
			humanoid.Health = 0
			humanoid.BreakJointsOnDeath = false
			wait(.1)
			Particle.Size = NumberSequence.new(2,3)
			wait(.1)
			humanoid.Parent.HumanoidRootPart.CFrame = SCP017.Parent.HumanoidRootPart.CFrame
			Particle.Size = NumberSequence.new(3,4)
			wait(.1)
			Particle.Size = NumberSequence.new(4,5)
			wait(.1)
			Particle.Size = NumberSequence.new(5,6)
			wait(.1)
			Particle.Size = NumberSequence.new(6,7)
			if humanoid then -- if Humanoid Exists
				for _,i in humanoid.Parent:GetDescendants() do -- iterates through Character
						if not i:IsA("Humanoid") then -- if Instances arent a Humanoid
						i:Destroy() -- Destroys Instances
					end
				end
			end
			wait(1)
			local Randomizer = math.random(1,8)
			if Randomizer == 1 then
				Sigh1:Resume()
				print("017 Taunt #1")
			elseif Randomizer == 2 then
				Sigh2:Resume()
				print("017 Taunt #2")
			elseif Randomizer == 3 then
				Sigh3:Resume()
				print("017 Taunt #3")
			elseif Randomizer == 4 then
				Sigh4:Resume()
				print("017 Taunt #4")
			elseif Randomizer == 5 then
				Sigh5:Resume()
				print("017 Taunt #5")
			elseif Randomizer == 6 then
				Sigh6:Resume()
				print("017 Taunt #6")
			elseif Randomizer == 7 then
				Sigh7:Resume()
				print("017 Taunt #7")
			elseif Randomizer == 8 then
				Sigh8:Resume()
				print("017 Taunt #8")
			end
			wait(2)
			Particle.Size = NumberSequence.new(6,6)
			wait(.01)
			Particle.Size = NumberSequence.new(5,5)
			wait(.01)
			Particle.Size = NumberSequence.new(4,4)
			wait(.01)
			Particle.Size = NumberSequence.new(3,3)
			wait(.01)
			Particle.Size = NumberSequence.new(2,2)
			wait(.01)
			SCP017.WalkSpeed = 50
		end
		if KillSoundRandomizer == 3 then
			SCP017.WalkSpeed = 0
			Killsound3:Play()
			Screamer:Play()
			humanoid.Health = 0
			humanoid.BreakJointsOnDeath = false
			wait(.1)
			Particle.Size = NumberSequence.new(2,3)
			wait(.1)
			humanoid.Parent.HumanoidRootPart.CFrame = SCP017.Parent.HumanoidRootPart.CFrame
			Particle.Size = NumberSequence.new(3,4)
			wait(.1)
			Particle.Size = NumberSequence.new(4,5)
			wait(.1)
			Particle.Size = NumberSequence.new(5,6)
			wait(.1)
			Particle.Size = NumberSequence.new(6,7)
			if humanoid then -- if Humanoid Exists
				for _,i in humanoid.Parent:GetDescendants() do -- iterates through Character
							if not i:IsA("Humanoid")  then -- if Instances arent a Humanoid
						i:Destroy() -- Destroys Instances
					end
				end
			end
			wait(5)
			local Randomizer = math.random(1,8)
			if Randomizer == 1 then
				Sigh1:Resume()
				print("017 Taunt #1")
			elseif Randomizer == 2 then
				Sigh2:Resume()
				print("017 Taunt #2")
			elseif Randomizer == 3 then
				Sigh3:Resume()
				print("017 Taunt #3")
			elseif Randomizer == 4 then
				Sigh4:Resume()
				print("017 Taunt #4")
			elseif Randomizer == 5 then
				Sigh5:Resume()
				print("017 Taunt #5")
			elseif Randomizer == 6 then
				Sigh6:Resume()
				print("017 Taunt #6")
			elseif Randomizer == 7 then
				Sigh7:Resume()
				print("017 Taunt #7")
			elseif Randomizer == 8 then
				Sigh8:Resume()
				print("017 Taunt #8")
			end
			wait(2)
			Particle.Size = NumberSequence.new(6,6)
			wait(.01)
			Particle.Size = NumberSequence.new(5,5)
			wait(.01)
			Particle.Size = NumberSequence.new(4,4)
			wait(.01)
			Particle.Size = NumberSequence.new(3,3)
			wait(.01)
			Particle.Size = NumberSequence.new(2,2)
			wait(.01)
			SCP017.WalkSpeed = 50
		end
	Killing.Value = false
	Attacking = false
	end 
end
script.Parent.Touched:connect(onTouch)

Monster #2:

local Occupied = false

local NoCommunication

local Stinger

function clone2521()
	local SCP2521 = game.ServerStorage.SCP2521:Clone()
	SCP2521.Parent = game.workspace
	
end
game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		for i = 1, #triggerwords do
			local word = triggerwords[i]
			local matchcheck = string.match(msg, word)
			if matchcheck ~= nil and Occupied == false then
				Occupied = true
				if word == "SCP2521" or "SCP-2521" or "SCP 2521" or "2521" or "2 5 2 1" or "two thousand five hundred twenty one" or "Twenty Five Twenty One" or "twenty five twenty one" or "Two Five Two One" or "two five two one" or "TwoFiveTwoOne" or "twofivetwoone" or "TwentyFiveTwentyOne" or "TwoThousandFiveHundredTwentyOne" or "Two Thousand Five Hundred Twenty One" then
					local victim = plr.Character
					clone2521()
					victim.Humanoid.WalkSpeed = 0
					victim.HumanoidRootPart.Anchored = true
					wait(math.random(2,3))
					workspace.SCP2521.Head.Music:Play()
					workspace.SCP2521.PlayAnimation.Disabled = false
					local LastTargetPosition = victim.HumanoidRootPart.CFrame
					local LookLength = -3
					workspace.SCP2521.HumanoidRootPart.CFrame = LastTargetPosition + LastTargetPosition.LookVector * LookLength
					workspace.SCP2521.HumanoidRootPart.CFrame = CFrame.new(workspace.SCP2521.HumanoidRootPart.CFrame.Position, Vector3.new(LastTargetPosition.Position.X, workspace.SCP2521.HumanoidRootPart.CFrame.Position.Y, LastTargetPosition.Position.Z))
					local Scream = workspace.SCP2521.Head.Scream
					wait(3.86)
						victim.HumanoidRootPart.CFrame = workspace.SCP2521.TakenSpot.CFrame
					wait(.3)
					Scream:Play()
					function Stinger()
						local SCP = workspace.SCP2521.HumanoidRootPart
	                    local Stinger = game.ServerStorage.Stinger:Clone()
                      	Stinger.Parent = workspace
						Stinger.CFrame = SCP.CFrame
					end
					Stinger()
					wait(.2)
					victim.HumanoidRootPart.CFrame = workspace.AreaOfInfinity.TeleportPartToGlitchedReality.CFrame
					function NoCommunication()
						local GoneScript = game.ServerStorage.GoneScript2521:Clone()
						GoneScript.Parent = victim
						GoneScript.Enabled = true
					end
					NoCommunication()
					victim.HumanoidRootPart.Anchored = false
					victim.Humanoid.WalkSpeed = 7.5
					workspace.SCP2521:Destroy()
					wait(1)
					Occupied = false
				end
		end
		end
		end)
	end)

I sincerely apologize for the messy/atrociously long code. I’m a newbie scripter, haha.

just do

if victim:FindFirstChild("HumanoidRootPart") then
--stuff related to HRP
end

since if it can find the item, it returns it and the if statement works. If it cant find HRP, it returns nil, which is falsy and wont activate the statement

1 Like

The above solution isn’t even necessary. In your code you should simply be able to do something like:

if victim.HumanoidRootPart then
  --Code
end

(I tried adapting it to your code, I don’t know how your system actually is meant to function). If the player has a HumanoidRootPart, the code will run, otherwise, it won’t.

1 Like

idky i’ve always been under the impression that while FindFirstChild returns nil if not found, literally just trying to get the children would error if not found

probably confused it with WaitForChild lol

1 Like

I’ve tried this already, the error still pops up. It’s really strange! And sorry, yes, it is super confusing to read my script when you dont have an illustration.

Monster #1 does this (I cut the video for funny purposes, you would see me teleport if I hadn’t cut it. You get the gist).


To get a better understanding, Monster #2 does this (His baseparts were destroyed in the dark)

So basically, when monster #2 destroys the baseparts, Monster #1 is unable to get their humanoid to teleport them to his “dimension”. Resulting in an error.

instead of destroying them could u not just set transparency to 1

1 Like

I’ve tried that, but it always ends up with something like “transparency is not a valid member of head.MeshPart”. You know any way to get around that?

I feel like I’m getting closer and closer to solving this. Thanks everyone.

idk what your original quote was, but are you sureeee mine also didn’t work??

ples send a version of your script WITH the double checking to make sure you checked correctly

and I think both me and propelled misunderstood. The error is happenning from monster 1?

so first, you dont have to check if humanoid exist twice. once is good enough

waaaait, is monster 2 teleporting you to a dimension or monster 1??? your code shows monster 1 destroying the baseparts, but you also said monster 1 does the teleport???

oh yea, and doesn’t monster 1 just completely kill you anyways? I dont see humanoid.RequireNeck set to false

1 Like

ya and if you use getDescendents wouldn’t that delete all things the the player except the Humanoid? that would literally just, like, kill the player, wouldn’t it??? (or atleast make them dissapear and become only a stationary camera)

1 Like

testing yours right now at the moment.
Yes, the error is happening from monster #1 (rising from the ground)
Monster #1 is teleporting you to another dimension. Monster #2 is the one stripping your bodyparts from the player.
No, Monster #1 teleports you to another dimension, in which you can walk around and find certain things. You cannot die in the dimension. You may only reset

I may just follow through with F0xBirdmansBFF’s plan to avoid any other trouble down the road.

There weren’t any more errors but, the script just stopped working.

Smart man. Why didn’t I think of that. It works!

if humanoid then -- if Humanoid Exists
				for _,i in humanoid.Parent:GetDescendants() do -- iterates through Character
					if i:IsA("BasePart") or i:IsA("Decal") then
						i.Transparency = 1
							end
						end
					end

This is what I replaced with Destroy:()
Thank you so much man. How didn’t I think of this? Lol. Thank you everyone that took their time to reply to this thread! :slight_smile:

srry for late reply:

if the script stops working, thats intended, as you cant really do anything to the player if it doesn’t have a base-part

yea fox’s idea is probably the best, but another way is to simply keep the humanoidRootPart, so the player TECHINICALLY still exists, is capable of movement, yet is literally a ghost

and make sure to mark f0x’s answer as the solution

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.