Hello, I have a store where players can try on and buy clothes (pants and shirts) from two StarterGui (try and buy)
The problem is that other players cannot see the clothes I am trying on.
I’m new to scripting and read somewhere that i need to add a “RemoteEvent” ( i can use a remote event that fires when you click on the try on button, allowing you to run the script on the server ).so that players can see what clothes are being tried on by others .
But I don’t know where or how to add this function, could someone help me?
Here the LocalScript:
> local MarketplaceService = game:GetService("MarketplaceService")
> local Players = game:GetService("Players");
>
> local client = Players.LocalPlayer;
> local PantsID;
> local template;
>
> for _, dummy in ipairs(workspace.Dummies:GetChildren()) do
> dummy.PantsClick.ClickDetector.MouseClick:Connect(function()
> PantsID = dummy.Pants.PantsID.Value;
> template = dummy.Pants.PantsTemplate;
> if script.Parent.Enabled == false and script.Parent.Parent.ShirtUI.Enabled == false then
> script.Parent.Enabled = true;
> if client.Character.Pants.PantsTemplate == template then
> end
> end
> end)
> end
>
> script.Parent.buttonframe.buyButton.MouseButton1Click:Connect(function()
> MarketplaceService:PromptPurchase(client, PantsID);
> script.Parent.Enabled = false;
> end)
>
>
> script.Parent.buttonframe.tryButton.MouseButton1Click:Connect(function()
> if client.Character.Pants.PantsTemplate == template then
> script.Parent.buttonframe.tryButton.TextLabel.Text = "Try On"
> script.Parent.Enabled = false
> else
> client.Character.Pants.PantsTemplate = template
> script.Parent.Enabled = false
> end
> end)
You could create a new remote event in replicated storage, then create a server script somewhere that checks when the remote event is fired and then changes the clothes. The local script that changes the clothes will fire the remote event with the ID of the clothes. If you wanted to be safe, you could check if the ID that was sent matches one in a table so players can’t wear anything. Sorry if I’m not detailed, I’m in school lol
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, clothesid)
--now you would find the character and change the clothes to the clothesid
end)```
game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent").OnServerEvent:Connect(function(plr, clothesid)
-- now you would find the character and change the clothes to the clothesid
end)
disclaimer: not tested, might not work. I don’t remember the name of the id property for pants or shirts. You could make it do a shirt instead as well.
Edit: Added script
Edit 2: Fixed property name
Edit 3: Added these edit things
Yes, PantsTemplate is the property name. The WaitForChild is optional, and I don’t often use them as they can yield the whole script from running. Maybe replace the WaitForChild with FindFirstChild.
but the problem is that I have several pants and shirts to buy in my shop, so that every clothes I try on, the other player can also see the clothes I wear on me
A roblox character can only wear one pants asset at a time. Therefore, you can’t make the character wear different pairs unless you cloned the user’s character to make like a hologram or something with the original character? I don’t know what you are going for here.
I think we are misunderstood, I don’t want us to be able to see all the pants at the same time, but every time I try pants in my shop, the other player can see everything I try on. for the moment here is what happens:
on the left the other player does not see my tries