Instancing doesnt work?

I made a blood script for roblox works fine. But when I want it to touch the ground and become a pool. This is my code:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(Character)
		Character.Humanoid.Died:Connect(function(KarlsonIsKill)

			Character.Head:Destroy()
			
			local count = 20
	

				local blood = Instance.new('Part')
				blood.Color = Color3.new(128, 0, 0)
				blood.Material = Enum.Material.Slate
				blood.Size = Vector3.new(0.1,0.5,0.1)
				blood.Parent = Character.Torso
				blood.CFrame = Character.Torso.CFrame 
				blood.Velocity = Character.Torso.CFrame.UpVector * 30
				
				
				Character.Torso.blood.Touched:Connect(function(PartTouched)
	
				local BloodRef = Character.Torso.blood
				local pool = Instance.new("Part")
				pool.CFrame = BloodRef.CFrame
				pool.Parent = game.Workspace
				pool.Shape = 'Cylinder'
				pool.Size = Vector3.new(2,0.3,2)
				pool.Color = Color3.new(128, 0, 0)
				pool.Anchored = true
				pool.Material = Enum.Material.Slate
				pool.CanCollide = false
				BloodRef:Destroy()
				
			

			end)
		end)
	end)
end)

But this is the part that doesn’t work:

Character.Torso.blood.Touched:Connect(function(PartTouched)
	
				local BloodRef = Character.Torso.blood
				local pool = Instance.new("Part")
				pool.CFrame = BloodRef.CFrame
				pool.Parent = game.Workspace
				pool.Shape = 'Cylinder'
				pool.Size = Vector3.new(2,0.3,2)
				pool.Color = Color3.new(128, 0, 0)
				pool.Anchored = true
				pool.Material = Enum.Material.Slate
				pool.CanCollide = false
				BloodRef:Destroy()
				
			

			end)
		end)
	end)
end)

Nothing happens. The code has no errors. it just doesn’t work.

Could you send the error or a screenshot of it?

Does the character have a part in it named “Torso”? Make sure you have R6 rig type turned on.

2 Likes

Adding on to what @EmeraldLimes said, it helps out a lot if you utilize HumanoidRootPart instead of Torso for this sort of thing so that your system won’t break if you decide to switch between R6 and R15.

1 Like

@SS4PPHIRE
image

The little red part is the part

and @EmeraldLimes it is r6 and does have torso in it. I’m not switching the game to r15 so I won’t need to use the root part.
As mentioned earlier, the problem lies here:

				Character.Torso.blood.Touched:Connect(function(PartTouched)
	
				local BloodRef = Character.Torso.blood
				local pool = Instance.new("Part")
				pool.CFrame = BloodRef.CFrame
				pool.Parent = game.Workspace
				pool.Shape = 'Cylinder'
				pool.Size = Vector3.new(2,0.3,2)
				pool.Color = Color3.new(128, 0, 0)
				pool.Anchored = true
				pool.Material = Enum.Material.Slate
				pool.CanCollide = false
				BloodRef:Destroy()
				
			

			end)
		end)
	end)
end)

BloodRef is the reference to the blood (Which works.)

And there are no errors popping up in output?

You didn’t name the blood part “blood” yet.

So, you are trying to find “blood” in the character torso, but the actual blood part’s name is just “Part”, because you have not named it yet.

You need to add this is your script:

blood.Name = "blood"
1 Like

Yes (Kinda):
image

The head is not a valid member, ignore that. When i click on the blood is not valid, it takes me here and puts my type line on the underlined line:

Adding onto what I said, instead of writing

Character.Torso.blood.Touched

you should probably write

blood.Touched

since, blood is the blood part that you just created.

Nope… Still doesn’t do anything (My newer code):

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(Character)
		Character.Humanoid.Died:Connect(function(KarlsonIsKill)

			Character.Head:Destroy()
			
			local count = 20
	

				local blood = Instance.new('Part')
				blood.Color = Color3.new(128, 0, 0)
				blood.Material = Enum.Material.Slate
				blood.Size = Vector3.new(0.1,0.5,0.1)
				blood.Parent = Character.Torso
				blood.CFrame = Character.Torso.CFrame 
				blood.Velocity = Character.Torso.CFrame.UpVector * 30
				
				
				blood.Touched:Connect(function(PartTouched)
	
				local BloodRef = Character.Torso.blood
				local pool = Instance.new("Part")
				pool.CFrame = BloodRef.CFrame
				pool.Parent = game.Workspace
				pool.Shape = 'Cylinder'
				pool.Size = Vector3.new(2,0.3,2)
				pool.Color = Color3.new(128, 0, 0)
				pool.Anchored = true
				pool.Material = Enum.Material.Slate
				pool.CanCollide = false
				BloodRef:Destroy()
				
			

			end)
		end)
	end)
end)

What exactly are you trying to achieve? What isn’t working?

I want to have a particle of blood drop down, create a flat circle in its place and then delete itself. Everything goes wrong at and after the touched event.

And what isn’t working?

(30 chars)

Do you have any errors in the output? If so please share them with me.

That code only runs when the player and the character is added

So put a local script inside of StarterCharacterScripts

then paste this code

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()

local hum = char.Humanoid

repeat wait() until hum -- basically waits for humanoid

hum.Died:Connect(function(KarlsonIsKill)
       -- insert code here
end)
2 Likes

The particle gets created normally but when it gets touched, nothing happens. There is an error that pops up but it doesnt give any info… All it says is: " [15:44:01.221 - blood is not a valid member of Part]

Could you please click that error and tell me what line of code it points you to?

1 Like

points me to the script. The cursor is here:

1 Like

You did not set the name to part set the part`s name to blood whenever you use Instance.new make sure to give it a name so you don’t forget about it

As I’ve said earlier, you need to set the name of the blood part to “blood”

1 Like