Try and buy clothings GUI

Hello, I have a store where players can try on and buy clothes (pants and shirts) from two StarterGui (try and buy)

284b9716beb7c8e592ed1072740f011a

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)

Thank you in advance !

1 Like

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

tell you about a script to place in SeverScriptService? do you have an example of what this script might look like?

The script might look like,

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, clothesid)
--now you would find the character and change the clothes to the clothesid
end)```

it doesn’t work, nothing happens :confused:

1 Like

Try this:

game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent").OnServerEvent:Connect(function(plr, clothesid)
	-- now you would find the character and change the clothes to the clothesid
end)

Nothing is supposed to happen yet, there are no lines inside of the function. You have to code that.
Example:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, clothesid)
   plr.Character.Pants.PantsTemplate = 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

maybe this?

game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent").OnServerEvent:Connect(function(plr, clothesid)
	plr.Character.Pants.PantsTemplate = clothesid
end)
1 Like

Additionally, when you use :FireServer(), you must pass a parameter of the ID.

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.

The delay (for me) is 6.3999905250967e-06 seconds

Is that a lot of time? I don’t think so

is this the full script? or do I have to add something? because I have tried all your suggestions, absolutely nothing happens…

Are you doing game.ReplicatedStorage.RemoteEvent:FireServer(ASSET-ID-OF-PANTS-HERE)?

(For the above line to work, replace ASSET-ID-OF-PANTS-HERE with the AssetId of your pants.)

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

Okay, could you clear up whether you want other people to be able to see it or not? I’m kind of confused.

yes, but not only one pant, but several

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

Oh, I see your problem. It could be an issue with how I change it, let me look.

1 Like