Hi developers, I tried a script from a person who helped me last time (thanks EXPLOSION_KING). This script puts certain clothes, accessories and hair on the player when he clicks on an image button. Now there is only one problem and that is I wanted the player to also be given a certain bundle so that certain characters with certain clothes don’t look weird (the sight of a male avatar wearing female clothes and accessories is a bit weird ). I have the bundle script (which might work) and the script that gives the player clothes and accessories, how can I connect this bundle script to the other script? Is that even possible?
(I’m not the best scripter so I would be happy if someone could explain to me how this works)
Bundle Script:
Newbundle = 382061
if MorphInfo.Bundle then
Humanoid.RequiresNeck = false
local function TryGet(context, object, funcName, ...)
local success, result = pcall(object[funcName], object, ...)
if success then
return result
else
warn("Invalid", context .. ':', ..., "(Error:", result .. ')')
end
end
local Bundle
local Info = TryGet("BundleId", AssetService, "GetBundleDetailsAsync", MorphInfo.Bundle)
if Info then
local Id = 0
for Index, Item in pairs(Info.Items) do
if Item.Type == "UserOutfit" then
Id = Item.Id
break
end
end
if Id > 0 then
Bundle = TryGet("Bundle", Players, "GetHumanoidDescriptionFromOutfitId", Id)
end
}
Humanoid:ApplyDescription(Bundle)
end
The working script that put clothings on the player:
local script place it in button.
local imageButton = script.Parent -- Reference to the ImageButton
local replicatedStorage = game:GetService("ReplicatedStorage")
local changeEvent = replicatedStorage:WaitForChild("ChangeClothesAndAccessories")
imageButton.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
if player then
changeEvent:FireServer()
end
end)
Normal sever script:
local replicatedStorage = game:GetService("ReplicatedStorage")
local serverStorage = game:GetService("ServerStorage")
local players = game:GetService("Players")
local changeEvent = replicatedStorage:WaitForChild("ChangeClothesAndAccessories")
-- New clothing and accessories IDs (Replace these with the actual asset IDs you want to use)
local newShirtId = 12118562014
local newPantsId = 12903182530
local newAccessories = {
17850329744,
17569661551,
-- Add more accessory IDs as needed
}
-- Function to remove old clothes and accessories
local function removeOldClothesAndAccessories(character)
-- Remove old clothes
for _, child in pairs(character:GetChildren()) do
if child:IsA("Shirt") or child:IsA("Pants") then
child:Destroy()
end
end
-- Remove old accessories
for _, child in pairs(character:GetChildren()) do
if child:IsA("Accessory") then
child:Destroy()
end
end
-- Remove old tools
for _, tool in pairs(character:GetChildren()) do
if tool:IsA("Tool") then
tool:Destroy()
end
end
end
-- Function to add new clothes and accessories
local function addNewClothesAndAccessories(character, player)
-- Add new shirt
local newShirt = Instance.new("Shirt", character)
newShirt.ShirtTemplate = "rbxassetid://" .. newShirtId
-- Add new pants
local newPants = Instance.new("Pants", character)
newPants.PantsTemplate = "rbxassetid://" .. newPantsId
-- Add new accessories
for _, accessoryId in ipairs(newAccessories) do
local success, accessoryModel = pcall(function()
return game:GetService("InsertService"):LoadAsset(accessoryId)
end)
if success then
local accessory = accessoryModel:FindFirstChildOfClass("Accessory")
if accessory then
accessory.Parent = character
end
accessoryModel:Destroy()
else
warn("Failed to load accessory with ID: " .. tostring(accessoryId))
end
end
-- Add new tools from ServerStorage
local vipToolsFolder = serverStorage:FindFirstChild("VIPTools")
if vipToolsFolder then
for _, tool in pairs(vipToolsFolder:GetChildren()) do
if tool:IsA("Tool") then
local clonedTool = tool:Clone()
clonedTool.Parent = player.Backpack
end
end
else
warn("VIPTools folder not found in ServerStorage")
end
end
-- Function to handle the RemoteEvent
local function onChangeClothesAndAccessories(player)
local character = player.Character or player.CharacterAdded:Wait()
removeOldClothesAndAccessories(character)
addNewClothesAndAccessories(character, player)
end
changeEvent.OnServerEvent:Connect(onChangeClothesAndAccessories)