Hi! This is stupid i just posted another form…
I’m making an RNG game yada yada and i got this error in my handler script.
ServerScriptService.AuraHandler:169: attempt to index nil with ‘Name’
the line of code:
warn(“The aura: " … auraName.Name … " was successfully destroyed!”)
the whole script:
local SS = game:GetService("ServerScriptService")
local RS = game:GetService("ReplicatedStorage")
local AnimationsConfig = require(RS.AnimationsConfig)
local SoundsConfig = require(RS.SoundsConfig)
local AuraHandler = {}
local activeAnimations = {}
local function hasAnimation(auraname)
local animationId = AnimationsConfig[auraname]
if animationId then
return true, animationId
else
return false
end
end
local function hasSound(auraname)
if SoundsConfig[auraname] ~= nil then
local soundID, volume, distance = SoundsConfig[auraname].SoundID, SoundsConfig[auraname].Volume, SoundsConfig[auraname].Distance
if soundID and volume and distance then
return true, soundID, volume, distance
else
return false
end
end
end
local function Animation(player, char, aura)
local result, animationId = hasAnimation(aura.Name)
if result then
warn(aura.Name .. " has an Animation")
local humanoid = char:FindFirstChildOfClass("Humanoid")
if not humanoid then
warn("No humanoid found for: " .. char.Name)
return
end
local animator = humanoid:FindFirstChildOfClass("Animator")
if not animator then
animator = Instance.new("Animator", humanoid)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://" .. tostring(animationId)
local animationTrack = animator:LoadAnimation(animation)
animationTrack:Play()
if not activeAnimations[player.UserId] then
activeAnimations[player.UserId] = {}
end
activeAnimations[player.UserId][aura.Name] = animationTrack
else
warn("No Animation found for: " .. aura.Name)
end
end
local function Sound(player, char, aura)
local result, soundID, volume, distance = hasSound(aura.Name)
if result then
local SoundInstance = char:FindFirstChild("HumanoidRootPart"):FindFirstChild("AuraSound")
if not SoundInstance or not SoundInstance:IsA("Sound") then
return
end
SoundInstance.SoundId = "rbxassetid://" .. soundID
SoundInstance.RollOffMaxDistance = distance
SoundInstance.Volume = volume
SoundInstance.Playing = true
end
end
function AuraHandler.EquipAura(player, char, aura)
if not player or not char or not aura then
warn("Missing parameters.")
return
end
local Auras = RS:FindFirstChild("Auras")
if not Auras then
warn("Auras folder not found in ReplicatedStorage.")
return
end
local auraToClone = Auras:FindFirstChild(aura.Name)
if not auraToClone then
warn(aura.Name .. " wasn't found in ReplicatedStorage!")
return
end
local auraFolder = char:FindFirstChild("AURA")
if not auraFolder then
auraFolder = Instance.new("Folder", char)
auraFolder.Name = "AURA"
end
if #auraFolder:GetChildren() > 0 then
warn("The aura: " .. auraFolder:GetChildren()[1].Name .. " is already equipped!")
return
end
local auraClone = auraToClone:Clone()
auraClone.Parent = auraFolder
local function cloneAndWeldParts(sourcePart, targetpart)
for _, part in ipairs(sourcePart:GetChildren()) do
if part:IsA("BasePart") then
local correspondingPart = targetpart:FindFirstChild(part.Name)
if correspondingPart then
local auraPartClone = part:Clone()
auraPartClone.Parent = correspondingPart
auraPartClone.CFrame = correspondingPart.CFrame
local weld = Instance.new("WeldConstraint")
weld.Part0 = correspondingPart
weld.Part1 = auraPartClone
weld.Parent = correspondingPart
end
elseif part:IsA("Model") then
local correspondingpart = targetpart:FindFirstChild(part.Name)
if correspondingpart then
cloneAndWeldParts(part, correspondingpart)
end
end
end
end
cloneAndWeldParts(auraClone, char)
if not auraFolder:FindFirstChild(aura.Name) then
local value = Instance.new("StringValue", auraFolder)
value.Name = aura.Name
end
Animation(player, char, { Name = aura.Name })
Sound(player, char, { Name = aura.Name })
warn(aura.Name .. " equipped to " .. char.Name)
end
function AuraHandler.UnequipAll(player, char)
if player and char then
local auraFolder = char:FindFirstChild("AURA")
if auraFolder then
local auraName = auraFolder:FindFirstChildWhichIsA("StringValue")
if activeAnimations[player.UserId] then
for auraName, animationTrack in pairs(activeAnimations[player.UserId]) do
animationTrack:Stop()
end
activeAnimations[player.UserId] = nil
end
local SoundInstance = char:FindFirstChild("HumanoidRootPart"):FindFirstChild("AuraSound")
if SoundInstance then
SoundInstance.SoundId = ""
SoundInstance.RollOffMaxDistance = 0
SoundInstance.Volume = 0
SoundInstance.TimePosition = 0
end
for _, child in ipairs(auraFolder:GetChildren()) do
if child:IsA("StringValue") then
child:Destroy()
end
end
warn("The aura: " .. auraName.Name .. " was successfully destroyed!")
auraName:Destroy()
end
end
end
return AuraHandler