How do I improve this script (aura gampass)

im doing aura gamepass for my game but my script doesnt look right.
How can i improve this script?

script:

local gamepassId = 21215800 – Gamepass ID
local service = game:GetService(“MarketplaceService”)
local RS = game:GetService(“ReplicatedStorage”)
local effect = RS:WaitForChild(“SPPAura”)

game.Players.PlayerAdded:Connect(function(player)
	if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then
		
		local hum = player.Character:WaitForChild("HumanoidRootPart")
		local hum2 = player.Character:WaitForChild("Left Arm")
		local hum3 = player.Character:WaitForChild("Left Leg")
		local hum4 = player.Character:WaitForChild("Right Arm")
		local hum5 = player.Character:WaitForChild("Right Leg")
		local hum6 = player.Character:WaitForChild("Torso")
		local hum7 = player.Character:WaitForChild("Head")
		
		effect:Clone()
		local e1 = effect:Clone()
		local e2 = effect:Clone()
		local e3 = effect:Clone()
		local e4 = effect:Clone()
		local e5 = effect:Clone()
		local e6 = effect:Clone()
		
		effect.Parent = hum
		e1.Parent = hum2
		e2.Parent = hum3
		e3.Parent = hum4
		e4.Parent = hum5
		e5.Parent = hum6
		e6.Parent = hum7
		
	end
end)
1 Like

Well looking at this and how you only put the aura on the body parts, you can simply just go through the character’s children and clone an effect for them if they’re parts

So fater the gamepass if statement you could do

for _, part in ipairs(character:GetChildren()) do
    if not part:IsA("BasePart") then
        continue
    end
    effect:Clone().Parent = part
end
1 Like