Why isn't Aura script working?

So i’m trying to make an aura script that parents an aura to every base part in the players character but this script only parented the auras to the humanoidrootpart and the head. Why?

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		for i, v in pairs(char:GetChildren()) do
			if v:IsA("BasePart") then
				local aura = game:GetService("ServerStorage"):WaitForChild("Aura"):Clone()
				aura.Parent = v
			end
		end
	end)
end)

also check for mesh parts
that is most likely the problem

i did this

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		for i, v in pairs(char:GetChildren()) do
			if v:IsA("BasePart") or v:IsA("MeshPart") then
				local aura = game:GetService("ServerStorage"):WaitForChild("Aura"):Clone()
				aura.Parent = v
			end
		end
	end)
end)

But it still did the same thing

try printing v
are you sure it’s only the head and hrp?

yes, and it printed every part in the character

You are instantly adding instances to the character when it hasn’t been fully loaded in, use WaitForChild on Humanoid and it should work.

Also you don’t need to check if it’s a MeshPart, BasePart covers all types of parts.

I tried this but it didn’t work, am i doing something wrong?

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		for i, v in pairs(char:GetChildren()) do
			if v:IsA("BasePart") then
				local aura = game:GetService("ServerStorage"):WaitForChild("Aura"):Clone()
				print(v)
				aura.Parent = char:WaitForChild(v.Name)
			end
		end
	end)
end

Oh wait i missed the on humanoid part

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
        char:WaitForChild("Humanoid")
		for i, v in pairs(char:GetChildren()) do
			if v:IsA("BasePart") then
				local aura = game:GetService("ServerStorage"):WaitForChild("Aura"):Clone()
				aura.Parent = v
			end
		end
	end)
end)

wasn’t that my original code that i had?
And it also didn’t work either, same thing happened

Another simple answer, just use wait(), possibly 1-3 seconds should fix.

1 Like