Hi I’m making an RNG game yada yada, i made an aura where there is a few objects and i would like it to be present when i equip the aura. but as far as i know it only equips the billboard gui and the attachment in the torso, so what i did was put the model in the head>billboard gui
but i very much expected it to work like the dumby i am and i need some help.
This is what it actually imports (which is what its supposed to)
The equip script may help with finding the problem so here,
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local PlayerDataStore = DataStoreService:GetDataStore("PlayerData")
local ServerStorage = game:GetService("ServerStorage")
local EquipEffectEvent = game:GetService("ReplicatedStorage"):WaitForChild("EquipEffect")
local GlobalData = ServerStorage:WaitForChild("PlayerData")
local Effects = ServerStorage:WaitForChild("Auras")
-- Function to load player data
local function loadPlayerData(player)
local playerFolder = Instance.new("Folder")
playerFolder.Name = player.UserId
playerFolder.Parent = GlobalData
local inventoryFolder = Instance.new("Folder")
inventoryFolder.Name = "Inventory"
inventoryFolder.Parent = playerFolder
local equippedFolder = Instance.new("Folder")
equippedFolder.Name = "CurrentlyEquipped"
equippedFolder.Parent = playerFolder
local success, data = pcall(function()
return PlayerDataStore:GetAsync(player.UserId)
end)
if success and data then
-- Load inventory
for _, itemName in ipairs(data.Inventory or {}) do
local item = Instance.new("StringValue")
item.Name = itemName
item.Parent = inventoryFolder
end
-- Load currently equipped items
for _, equippedItem in ipairs(data.CurrentlyEquipped or {}) do
local item = Instance.new("StringValue")
item.Name = equippedItem
item.Parent = equippedFolder
end
-- Equip the currently equipped items
for _, item in pairs(equippedFolder:GetChildren()) do
equip(player, item.Name, equippedFolder)
end
end
end
-- Function to save player data
local function savePlayerData(player)
local playerFolder = GlobalData:FindFirstChild(player.UserId)
if playerFolder then
local inventory = {}
local currentlyEquipped = {}
for _, item in pairs(playerFolder.Inventory:GetChildren()) do
table.insert(inventory, item.Name)
end
for _, item in pairs(playerFolder.CurrentlyEquipped:GetChildren()) do
table.insert(currentlyEquipped, item.Name)
end
local data = {
Inventory = inventory,
CurrentlyEquipped = currentlyEquipped
}
pcall(function()
PlayerDataStore:SetAsync(player.UserId, data)
end)
end
end
-- Equip and unequip functions
local function delete(player, selectedEffect, CurrentlyEquippedFolder)
local head = player.Character:FindFirstChild("Head")
local torso = player.Character:FindFirstChild("Torso")
CurrentlyEquippedFolder:ClearAllChildren()
if head and torso and selectedEffect then
for _, v in pairs(head:GetChildren()) do
if v.Name == selectedEffect or v:IsA("BillboardGui") or v:IsA("Attachment") then
v:Destroy()
end
end
for _, v in pairs(torso:GetChildren()) do
if v.Name == selectedEffect or v:IsA("BillboardGui") or v:IsA("Attachment") then
v:Destroy()
end
end
end
end
function equip(player, selectedEffect, CurrentlyEquippedFolder)
local effect = Effects:WaitForChild(selectedEffect)
local title = effect:WaitForChild("Head"):WaitForChild(selectedEffect):Clone()
local particles = effect:WaitForChild("Torso"):WaitForChild(selectedEffect):Clone()
local character = player.Character or player.CharacterAdded:Wait()
title.Parent = character.Head
particles.Parent = character.Torso
local stringVal = Instance.new("StringValue")
stringVal.Name = selectedEffect
stringVal.Parent = CurrentlyEquippedFolder
end
-- Main equipEffect function
local function equipEffect(player, operationType, selectedEffect)
local PlayerDataFolder = GlobalData:WaitForChild(player.UserId)
local InventoryFolder = PlayerDataFolder:WaitForChild("Inventory")
local CurrentlyEquippedFolder = PlayerDataFolder:WaitForChild("CurrentlyEquipped")
if operationType == "Equip" and selectedEffect then
if InventoryFolder:FindFirstChild(selectedEffect) then
if #CurrentlyEquippedFolder:GetChildren() ~= 0 and CurrentlyEquippedFolder:GetChildren()[1].Name ~= selectedEffect then
delete(player, CurrentlyEquippedFolder:GetChildren()[1].Name, CurrentlyEquippedFolder)
end
if #CurrentlyEquippedFolder:GetChildren() == 0 or CurrentlyEquippedFolder:GetChildren()[1].Name ~= selectedEffect then
equip(player, selectedEffect, CurrentlyEquippedFolder)
end
end
elseif operationType == "delete" and selectedEffect and CurrentlyEquippedFolder:FindFirstChild(selectedEffect) then
delete(player, selectedEffect, CurrentlyEquippedFolder)
end
end
-- Connect equipEffect function to the event
EquipEffectEvent.OnServerEvent:Connect(equipEffect)
-- Load data when player joins
Players.PlayerAdded:Connect(function(player)
loadPlayerData(player)
end)
-- Save data when player leaves
Players.PlayerRemoving:Connect(function(player)
savePlayerData(player)
end)
I am aware that in the script it tries to equip the billboard gui and its DESCENDANTS, so thats kind of where the thought came to mind.
Thank you sosososos much I would really love to get this fixed.
Antlers