Hello, I am new to the Devforum and i would like to know how to make a GUI accessory shop thing. Is there any other way than making a folder in replicated storage and then sending a remote event to equip the accessory on your character?
I will guide you through a simple way to make an accessory-equip system. The only thing youâll want to have previous knowledge on are remote events and welding. To begin with, youâll want to construct a simple UI button. Youâll want to add a local script under the button and add some code. This code will fire a remote event to the server telling the server to equip an accessory once the UI button is pressed (button.MouseButton1Down:Connect(function()).
Local Script
button.MouseButton1Down:Connect(function() --Detect when the button is pressed
RemoteEvent:FireServer("Equip Accessory", accessory) --Fire an event to the server
end)
On the server-side, when it receives the event, youâll want to equip the accessory to the player. To keep everything organized, I suggest creating a folder named âAccessoriesâ in the ReplicatedStorage that holds all the accessories. If the accessory is a âtraditionalâ accessory, then there will be no need to weld it. If itâs a custom hat without any preset welds, then youâll have to weld it manually through a script. Letâs say you just want to clone a regular accessory to the player. To achieve this, youâre code should look similar to this, Sever Sided Script
local RemoteEvent = pathToRemoteEvent
RemoteEvent.OnServerEvent:Connect(function(player, topic, info) --Receive the event
if topic == "Equip Accessory" then
local newAccessory = info:Clone() --Clone the accessory
newAccessory.Parent = player.Character --Place the accessory into the player's character
end
end)
Iâve made an accessory shop before. If youâre going to be using items from the Avatar Shop you should then use the HumanoidDescription System as it very much simplifies applying shirts, pants, hats, hairs, body colors, or whatever you can normally put on your character.
Look above at @McRocketNuggetsâ post for his explanation of remote events as the server must be doing the changing.