#Aura
1 messages · Page 1 of 1 (latest)
do you want to reply to this or me lol, i have some code to share
what i would do for equiping auras is to give each player a string variable with the name of their aura and keep the auras themselves in server storage.
then have an event that fires whenever the player equips an aura that deletes their current aura and places a copy of the selected aura into the player
i dont have code rn go ahead lol
local SS = game:GetService("ServerScriptService")
local RS = game:GetService("ReplicatedStorage")
local AuraHandler = {}
function AuraHandler.EquipAura(player, char, aura)
if not player or not char or not aura then
warn("missing perameters.")
return
end
local Auras = RS:FindFirstChild("Auras")
if not Auras then return end
if not Auras:FindFirstChild(aura.name) then
warn(aura.name .. "wasnt 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 equipt")
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, char)
if not auraFolder:FindFirstChild(aura.name) then
local value = Instance.new("StringValue", auraFolder)
value.name = aura.name
end
-- Animation
-- Sound
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("Folder")
--Animiations
--Sound
for _, child in char:GetChildren() do
for _, secondChild in child:GetChildren() do
if secondChild.name == child.name then
secondChild:destroy()
end
end
end
warn("the aura" .. auraName.name .. "was sucessfully destroyed")
auraName:destroy()
end
end
end
return AuraHandler
this is the code i used to weld the parts onto the body, make sure this code is pasted into a module script inside of serverscriptservice
just make sure that you have a folder inside of Replicated storage called "Auras"
** You are now Level 1! **
inside the Auras folder create another folder called whatever your aura called
inside that folder add a part and set the invisibility to false
make sure the part is named the exact same as the part your welding them to
like this
the last thing you will have to do is to create a script inside of serverscriptservice with this code
local SS = game:GetService("ServerScriptService")
local RS = game:GetService("ReplicatedStorage")
local AuraModule = require(SS.AuraHandler)
local Auras = RS.Auras
local Remotes = RS.Remotes
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local AurasFolder = Instance.new("Folder", char)
AurasFolder.Name = "AURA"
end)
end)
Remotes.AuraEquip.OnServerEvent:Connect(function(player, aura)
local char = player.Character
AuraModule.EquipAura(player, char, aura)
end)
Remotes.AuraUnequipAll.OnServerEvent:Connect(function(player)
local char = player.Character
AuraModule.UnequipAll(player, char)
end)
with this code you need to make sure you have a folder called remotes inside of Replicated storage with the labeled remotes
To actually equip and unequip you will need to make a ui button with a local script that "fires" the event you made remotely
you can use this for it
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Remotes.AuraUnequipAll:FireServer()
end)
and vice versa with the Auraequip event
I hope this works for you, and if it doesnt make sure all your variable names are the same as mine or mine are the same as yours
if all else fails ask ai assistant to help
if you need me to explain anything to make it easier to understand i can