Hello I am trying to make a character shop, after the player clicks the button, they respawn, I have tried for hours and I can’t seem to find a solution; heres what I have:
You could try using humanoid description. Instead of resetting the player and using a Starter Character. If you’re using a local script, you need to use a normal script, or it won’t work. If you decide to do this route someone could possibly reset at the same time someone changed their avatar and they could have the same custom avatar. So, you should just use humanoid description as it will help your situation a lot.
-- Variables
local plr = game.Players.LocalPlayer -- Variable for the player
local char = plr.Character -- variable for the character
local Character1 = {
HatAccessory = 1, -- ID of the accessories.
NeckAccessory = 1,
ShouldersAccessory = 1,
WalkAnimation = "rbxassetid://1", -- ID of the animations.
JumpAnimation = "rbxassetid://1",
HeadColor = Color3.new(1, 1, 0.498039), -- Color3 used for body colors.
TorsoColor = Color3.new(1, 1, 0.498039),
Tshirt = "123", -- ID of the t shirt
Shirt = "12345",-- ID of the shirt
Pants = "1234", -- ID of the pants
}
local Character2 = {
HatAccessory = 2, -- ID of the accessories.
NeckAccessory = 2,
ShouldersAccessory = 2,
WalkAnimation = "rbxassetid://2", -- ID of the animations.
JumpAnimation = "rbxassetid://2",
HeadColor = Color3.new(1, 1, 0.498039), -- Color3 used for body colors.
TorsoColor = Color3.new(1, 1, 0.498039),
Tshirt = "123", -- ID of the t shirt
Shirt = "12345",-- ID of the shirt
Pants = "1234", -- ID of the pants
}
script.Parent.MouseButton1Click:Connect(function() -- functions on mouse click
if char.Humanoid:FindFirstChild("HumanoidDescription") then -- Checks if there is a humanoid description
local HumanoidDescription = char.Humanoid:FindFirstChild("HumanoidDescription")
-- Accessories
HumanoidDescription.HatAccessory = Character1.HatAccessory
HumanoidDescription.NeckAccessory = Character1.NeckAccessory
HumanoidDescription.ShouldersAccessory = Character1.ShouldersAccessory
-- Animations
HumanoidDescription.WalkAnimation = Character1.WalkAnimation
HumanoidDescription.JumpAnimation = Character1.JumpAnimation
-- Body Colors
HumanoidDescription.HeadColor = Character1.HeadColor
HumanoidDescription.TorsoColor = Character1.TorsoColor
-- Clothes
HumanoidDescription.Shirt = Character1.Shirt
HumanoidDescription.GraphicTShirt = Character1.Tshirt
HumanoidDescription.Pants = Character1.Pants
else -- If no humanoid description
local HumanoidDescription = Instance.new("HumanoidDescription", char.Humanoid) -- Makes a new instance which is a humanoiddescription
-- Accessories
HumanoidDescription.HatAccessory = Character1.HatAccessory
HumanoidDescription.NeckAccessory = Character1.NeckAccessory
HumanoidDescription.ShouldersAccessory = Character1.ShouldersAccessory
-- Animations
HumanoidDescription.WalkAnimation = Character1.WalkAnimation
HumanoidDescription.JumpAnimation = Character1.JumpAnimation
-- Body Colors
HumanoidDescription.HeadColor = Character1.HeadColor
HumanoidDescription.TorsoColor = Character1.TorsoColor
-- Clothes
HumanoidDescription.Shirt = Character1.Shirt
HumanoidDescription.GraphicTShirt = Character1.Tshirt
HumanoidDescription.Pants = Character1.Pants
end
end)
You can also use the properties of HumanoidDescription to change the skin color, clothing, animations and body rig type.
local plr = game.Players.LocalPlayer
local char = plr.Character
local Character1 = {
HatAccessory = 1, -- ID of the accessories.
NeckAccessory = 1,
ShouldersAccessory = 1,
WalkAnimation = "rbxassetid://1", -- ID of the animations.
JumpAnimation = "rbxassetid://1",
HeadColor = Color3.new(1, 1, 0.498039), -- Color3 used for body colors.
TorsoColor = Color3.new(1, 1, 0.498039),
Tshirt = "123", -- ID of the t shirt
Shirt = "12345",-- ID of the shirt
Pants = "1234", -- ID of the pants
}
local Character2 = {
HatAccessory = 2, -- ID of the accessories.
NeckAccessory = 2,
ShouldersAccessory = 2,
WalkAnimation = "rbxassetid://2", -- ID of the animations.
JumpAnimation = "rbxassetid://2",
HeadColor = Color3.new(1, 1, 0.498039), -- Color3 used for body colors.
TorsoColor = Color3.new(1, 1, 0.498039),
Tshirt = "123", -- ID of the t shirt
Shirt = "12345",-- ID of the shirt
Pants = "1234", -- ID of the pants
}
script.Parent.MouseButton1Click:Connect(function()
if char.Humanoid:FindFirstChild("HumanoidDescription") then
local HumanoidDescription = char.Humanoid:FindFirstChild("HumanoidDescription")
-- Accessories
HumanoidDescription.HatAccessory = Character1.HatAccessory
HumanoidDescription.NeckAccessory = Character1.NeckAccessory
HumanoidDescription.ShouldersAccessory = Character1.ShouldersAccessory
-- Animations
HumanoidDescription.WalkAnimation = Character1.WalkAnimation
HumanoidDescription.JumpAnimation = Character1.JumpAnimation
-- Body Colors
HumanoidDescription.HeadColor = Character1.HeadColor
HumanoidDescription.TorsoColor = Character1.TorsoColor
-- Clothes
HumanoidDescription.Shirt = Character1.Shirt
HumanoidDescription.GraphicTShirt = Character1.Tshirt
HumanoidDescription.Pants = Character1.Pants
else
local HumanoidDescription = Instance.new("HumanoidDescription", char.Humanoid)
-- Accessories
HumanoidDescription.HatAccessory = Character1.HatAccessory
HumanoidDescription.NeckAccessory = Character1.NeckAccessory
HumanoidDescription.ShouldersAccessory = Character1.ShouldersAccessory
-- Animations
HumanoidDescription.WalkAnimation = Character1.WalkAnimation
HumanoidDescription.JumpAnimation = Character1.JumpAnimation
-- Body Colors
HumanoidDescription.HeadColor = Character1.HeadColor
HumanoidDescription.TorsoColor = Character1.TorsoColor
-- Clothes
HumanoidDescription.Shirt = Character1.Shirt
HumanoidDescription.GraphicTShirt = Character1.Tshirt
HumanoidDescription.Pants = Character1.Pants
end
end)
This is for all the other properties. You can make multiple characters.
Providing the keys/fields of the table match the properties of a HumanoidDescription instance you can do the following.
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local description = humanoid:GetAppliedDescription()
local button = script.Parent
local customCharacter = {
--Properties & values go here.
}
button.MouseButton1Click:Connect(function()
description = description or Instance.new("HumanoidDescription")
description.Parent = description.Parent or humanoid
for descriptionProperty, descriptionValue in pairs(customCharacter) do
description[descriptionProperty] = descriptionValue
end
humanoid:ApplyDescription(description)
end)
Are you putting the ids of accessories or shirts? It can’t be an id of something else. You can go to the avatar shop and click a item and copy the numbers and paste it.