hello, so my issue here is that i gotta press a button and then it should call the functions for a specific person (here, i put my own user). but it says " ServerScriptService.AuraHandler:69: attempt to index nil with ‘Character’ " (AuraHandler is the module script). here are the scripts:
LOCALSCRIPT IN THE BUTTON
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Remotes.AuraUnequipAll:FireServer(game.Players.Kyhomi)
wait(0.1)
game.ReplicatedStorage.Remotes.AuraEquip:FireServer(game.Players.Kyhomi, game.ReplicatedStorage.Auras.Unique) --Unique is the name of the aura and Kyhomi is my username
end)
MODULE SCRIPT IN SERVERSCRIPTSERVICE
--i only put the functions but the rest (local module, return module... are just hidden)
function AuraHandler.EquipAura(player, char, targetplr, aura)
local targetchar = targetplr.Character
if not targetplr or not targetchar or not aura then
warn("Missing parameters.")
return
end
local Auras = rs:FindFirstChild("Auras")
if not Auras then return end
if not Auras:FindFirstChild(aura.Name) then
warn(aura.Name .. " wasn't found in ReplicatedStorage.")
return
end
local aurafolder = targetchar:FindFirstChild("Aura")
if not aurafolder then
aurafolder = Instance.new("Folder", targetchar)
aurafolder.Name = "Aura"
end
if #aurafolder:GetChildren() > 0 then
warn("The aura: " .. aurafolder:GetChildren()[1].Name .. " is already equipped.")
return
end
local auraclone = Auras[aura.Name]: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, targetchar)
if not aurafolder:FindFirstChild(aura.Name) then
local value = Instance.new("StringValue", aurafolder)
value.Name = aura.Name
end
Animation(targetplr, targetchar, {Name = aura.Name})
Sound(targetplr, targetchar, {Name = aura.Name})
warn(aura.Name .. " equipped to " ..targetchar.Name)
end
function AuraHandler.UnequipAll(player, char, targetplr)
local targetchar = targetplr.Character
if targetplr and targetchar then
local aurafolder = targetchar:FindFirstChild("Aura")
if aurafolder then
local auraname = aurafolder:FindFirstChildWhichIsA("Folder")
if activeAnimations[targetplr.UserId] then
for auraName, animationtrack in pairs(activeAnimations[targetplr.UserId]) do
animationtrack:Stop()
end
activeAnimations[targetplr.UserId] = nil
end
local soundinstance = targetchar:FindFirstChild("HumanoidRootPart"):FindFirstChild("AuraSound")
if soundinstance then
soundinstance.SoundId = ""
soundinstance.RollOffMaxDistance = 0
soundinstance.Volume = 0
soundinstance.TimePosition = 0
end
for _, child in ipairs(targetchar:GetChildren()) do
for _, secondChild in ipairs(child:GetChildren()) do
if secondChild.Name == child.Name then
secondChild:Destroy()
end
end
end
warn("The aura: " .. auraname.Name .. " was successfully destroyed.")
auraname:Destroy()
end
end
end
SERVER SCRIPT IN SERVERSCRIPTSERVICE
--remotes is a folder in replicatedstorage with the remote events
remotes.AuraEquip.OnServerEvent:Connect(function(player, char, targetplr, aura)
local char = player.Character
auramodule.EquipAura(player, char, targetplr, aura)
end)
remotes.AuraUnequipAll.OnServerEvent:Connect(function(player, char, targetplr)
local char = player.Character
auramodule.UnequipAll(player, char, targetplr)
end)
thanks for ur help