Character is not a valid member of "MeshPart"?

So I made a system where if you touch a block it will teleport you to another part, but the problem is that I keep getting these mass errors that spam the output “Character is not a valid member of “MeshPart””
afbeelding

I’m getting real confused here

code:

script.Parent.Touched:Connect(function(player)

	player.Character.HumanoidRootPart.CFrame = game.Workspace.Buildings.JerryDeli.TPPart2.CFrame

end)

Thanks.

2 Likes

Touched returns the part that touched something, not the player

You need to make code that works for that, soemthing like this

	
script.Parent.Touched:Connect(function(hit)
	
	if game.Players:GetPlayerFromCharacter(hit.Parent) and hit.Parent.Humanoid.Health ~= 0 then --If Parent of the hit part is a player and is alive
		hit.Parent.HumanoidRootPart.CFrame = game.Workspace.Buildings.JerryDeli.TPPart2.CFrame
	end

end)
6 Likes

Dam bruh, I haven’t used the touched function ina bit, I totally forgot about that, thank you.

3 Likes

Anytime! Just remember to do a condition to check if the part belongs to a player/npc so it will work! If you have anymoer issues don’t be afraid to make another post!

2 Likes

Alright, thanks for the help, really appreciate it.

3 Likes