How to Implement Model into Aura?

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

image

but i very much expected it to work like the dumby i am and i need some help.
image
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 :slight_smile:

1 Like

We can use the WeldConstraint instance to attach the Effects Model to the Character Model

Change your equip function to this:

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 model = title:FindFirstChildOfClass("Model")
	while not model or model.ClassName ~= "Model" do
		model = title.ChildAdded:Wait()
	end

	local character = player.Character or player.CharacterAdded:Wait()
	title.Parent = character.Head
	particles.Parent = character.Torso
	model.Parent = character
	model:PivotTo(character:GetPivot())
	for _, basePart in model:GetDescendants() do
		if not basePart:IsA("BasePart") then
			continue
		end
		if basePart.Anchored then
			basePart.Anchored = false
		end
		local weldConstraint = Instance.new("WeldConstraint", model)
		weldConstraint.Part0 = character.Torso
		weldConstraint.Part1 = basePart
	end

	local stringVal = Instance.new("StringValue")
	stringVal.Name = selectedEffect
	stringVal.Parent = CurrentlyEquippedFolder
end
1 Like

THANK U SO MUCH U ACTUALLY SAVED MY LIFE… uhh sorry but if you dont mind i really need help with this other thing and ur such a genius that if u could help me that would be AMAZING TYSM :heart: Save Inventory After Leaving

Oh shoot im sorry but i found another bug IM SO SORRY BRO :sob:


If you dont feel like helping me any further i totally get haha its okay

What’s the bug here? Make sure you positioned the models correctly in the title.

1 Like

Im SO sorry but i dont really know what do you mean by that.

i’ve been trying to assign its position Y value to 9.532 to make it go up but it just stays there no matter what. the redirection is corrcet

Can you send the .rbxm file of the of the title billboardgui with the model inside of it?

1 Like

Of course!

Puppet.rbxm (18.3 KB)

Thank you so much by the way it means a lot

Try this:

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 model = title:FindFirstChildOfClass("Model")
	while not model or model.ClassName ~= "Model" do
		model = title.ChildAdded:Wait()
	end
	
	local pivotOffset = effect:GetPivot():ToObjectSpace(model:GetPivot())
	local character = player.Character or player.CharacterAdded:Wait()
	model:PivotTo(character:GetPivot() * pivotOffset)
	
	title.Parent = character.Head
	particles.Parent = character.Torso
	model.Parent = character
	for _, basePart in model:GetDescendants() do
		if not basePart:IsA("BasePart") then
			continue
		end
		if basePart.Anchored then
			basePart.Anchored = false
		end
		local weldConstraint = Instance.new("WeldConstraint", model)
		weldConstraint.Part0 = character.Torso
		weldConstraint.Part1 = basePart
	end

	local stringVal = Instance.new("StringValue")
	stringVal.Name = selectedEffect
	stringVal.Parent = CurrentlyEquippedFolder
end
1 Like

It’s very good thank you! Only thing thats missing is the rope constraints but that was already in there so is there an easy way you can do that to keep the visible ropes? Im so sorry for dragging this on!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.