I was making an accessory shop and i had made my own accessory.
I want to equip that accessory.
I decided to clone the accessory. here’s the code
script.Parent.MouseButton1Click:Connect(function()
local skirt = game.ReplicatedStorage["Classic Lolita Skirt"]
local copy = skirt:Clone()
copy.Parent = game.ReplicatedStorage
copy.Name = "ClassicSkirt"
local event = game.ReplicatedStorage.Remotes.ClassicBuy
local skirt = game.ReplicatedStorage:WaitForChild("ClassicSkirt")
event:FireServer(skirt)
end)
and in the serverscriptservice
repstorage = game.ReplicatedStorage
Event = repstorage.Remotes:WaitForChild("ClassicBuy")
Event.OnServerEvent:Connect(function(Plr, copy)
local Character = Plr.Character
local Name = Character.Name
if not Character:FindFirstChild(Name) then
local humanoid = Character:FindFirstChild("Humanoid")
humanoid:AddAccessory(copy)
else
print("AldreadyEquipped")
end
end)
I saw the skirt cloned in repstorage
but when i press the button, it shows this
09:24:51.722 - AddAccessory should be passed a valid Accessory object.
09:24:51.725 - Stack Begin
09:24:51.725 - Script 'ServerScriptService.Script', Line 8
09:24:51.725 - Stack End
Do kindly help me.