How to put particles on humanoid's arms and Head?

Hello devs, i am a new developer that just learned lua, and i was trying to put some particles on humanoid’s Arms And Head. But I dont know how to do it.

Im doing this By the OnTouched Event

My Character is R6

This is a problem that ive been trying to solve for 1 week.

The script below is from my last topic that was “Solved”

//Services
local ServerStorage = game:GetService(“ServerStorage”)

	--//Variables
	local Particle115 = ServerStorage.kills115
	local Character = script.Parent

	--//Tables
	local ValidParts = {
		"Right Arm"
	}

	--//Functions
	for i, child in pairs(Character:GetChildren()) do
		print(child)
		if ValidParts[child.Name] then
			print("found in table")
			local Particle = Particle115:Clone()
			Particle.Parent = child
		end
	end

The problem is when i touch, the script prints the “child” but doesnt print the “found in table”
also, the script doesnt give any errors, and i cant fix that.

Any Help will be really helpful!

“Right Arm” is just a string value in the table not an index. you need to replace it with [“Right Arm”] = true or something like that

You say that this is a touched event, but I don’t see touched anywhere. Is this inside of a touched script? If so, on line 3 you set Character to script.Parent instead of setting Character to the parent of what hit the script’s parent.
Example:

script.Parent.Touched:Connect(funtion(hit)
local Character = hit.Parent
end)

Edit: One thing about your table: you checking if theres a key in your table called “Right Arm”. There are only keys in a table if the table is a dictionary. Either convert you table into a dictionary or use table.find()

Example:

script.Parent.Touched:Connect(funtion(hit)
	local Character = hit.Parent
	for i,v in pairs(Character:GetChildren()) do
		if table.find(ValidParts, v.Name) == nil then continue end
		print("found in table")
		local Particle = Particle115:Clone()
		Particle.Parent = child
	end
end)
1 Like

Still din’t work, it do the same thing, prints but nothing happens

Also, the script has some errors.

–funtion

–child (the script says child does not exist)

--//Variables
	local Particle115 = ServerStorage.kills115
	local Character = script.Parent

	--//Tables
	local ValidParts = {
		"Right Arm"
	}

	--//Functions
local function findStringInTable(tbl, str)
    for _, element in pairs(tbl) do
        if (element == str) then
            return true
        end
    end
    return false
end

	for i, child in pairs(Character:GetChildren()) do
		print(child)
		if findStringInTable(ValidParts, child.Name)  then
			print("found in table")
			local Particle = Particle115:Clone()
			Particle.Parent = child
		end
	end

maybe something like this would work? @tutizillig

Have you tested your particle emitter on a part first to see if the particle emitter actually works?

Why did you never say this before? :sob:

1 Like

Yes, and it works, Also tested in a dummy too.

Oh, im sorry, i forgot to say that since the script was only printing Weld, TouchInterest and the
name of the script. @CipherFunctions

still din’t work, i dont know what to do anymore. =(

What does the script currently print?

Weld

TouchInterest

Particle (Name of the script)

As i said in my previous post, this is likely because you set character to script.Parent instead of hit.Parent

It prints the following for this code?

Weld
TouchInterest
Particle

What’s hit.Parent? Where’s hit defined?

in the op they said they were using with an onTouched event, which comes with hit.

I didn’t see that. @tutizillig Please provide full code for context.

Yes, is this was supposed to happen?

No. Please give us your full script.