Finding an ID from a model using a Server Script Storage script

Hello, I am trying to make a home store for my group and aiming to make a mannequin that looks/performs better which should hopefully make the shopping experience smoother for customers. When the mannequin is clicked, it prompts the purchase depending if you clicked on the ShirtBlock or PantBlock (So you don’t click the entire model). If you can help in any way like linking a tutorial, a different way to achieve what I’m doing, or really anything please do so!

What I’m hoping to achieve
Basically, I’m trying to code it so that instead of having a script in each individual mannequin to prompt the purchase, I’ll only have two in server script storage. I have no idea how I can grab the IDs from the mannequins to prompt the purchase when a player clicks on the mannequin. I was going to use a GUI to prompt purchase but I figured if i couldn’t prompt the purchase with a script in the Server Script Storage then I should just stick to that first then work on coding the GUI. The reason I’m doing this is so it should be easier to set up mannequins as you only need to change the 4 items in each model.

Picture of Explorer (I'm using NumberValues to store the IDs)

If you know how to get the shirt ID from the humanoid’s Shirt please share, because I only know how to call on the NumberValue in a script.

Script that I have so far (Not much)

Sorry it’s practically an empty script, I don’t have much experience in coding.
image
I don’t know how to prompt a purchase using the click detector as the script isn’t in the workspace anymore or “grab” the ID from the mannequins when click on.

GUI

If this helps to show you what I was looking to achieve.
image
image

If you have any questions, please ask! Thank you for reading, I appreciate it!

You would probably use for i,v in pairs and loop through all the mannequins. Then you would get the click detector and set MouseClick function. When its clicked, you could check the Id in the mannequin itself and then fire a remote event to the client to prompt the purchase.

1 Like

If this is just a clothing store game, you could do all of this in a local StarterPlayerScript instead. You can constantly check Mouse.Target using Renderstepped to find out what your cursor is hovering over. I’d recommend creating an invisible part around the mannequin model for being detected by Mouse.Target.

I’d still use IntValues to store the IDs in the mannequin, preferably under the invisible part for ease of access. Use renderstepped to find which invisible part your cursor is hovering over, then use UserInputService to handle clicking to prompt the UI.

Basically, if Mouse.Target is a mannequin brick, and UserInputService detects a left mouse button click, then activate the UI / purchase prompt, whatever it may be.

( Yes, purchases can be prompted locally. )

1 Like

Thank you so much for responding! I was able to use those services to prompt purchases, but is there a way to do this so it can work on Tablets/Phones and to reduce lag when clicking on the mannequins? If someone spam clicks a mannequin it breaks their game. Anything that you can think of helps!

If you are referring to purchase prompt lag, there doesn’t really seem to be a way around this ( as far as I know. )

Recently I’ve noticed prompts have become much more delayed than they used to be.

1 Like