Purchase GUI Prompt

Hi, so I am trying to make a GUI that allows players to purchase a shirt, however, I have ran into some issues that I can’t solve!

Basically I get this error code:
image

And here is the code for my UI button:
image

You have to change the shirtID number value to the ID of the shirt

/\ I’ve done that but it seems to still do it! I think it’s something to do with getting the player?

You can’t get the player within the function() parameters when doing MouseButton1Down. Also you can’t purchase stuff in a Server Script, only in a Client Script.

Oh okay, I’ll try that now! Thank you :slight_smile: .

Can you show me where the script is located in the GUI? Thanks.

Sure! image

Write down:

local player = script.Parent.Parent.Parent.Parent.Parent

Okay! Thank you :slight_smile: !

It works! Thank you so much! I am still new to coding so I am learning new things as I go!

Don’t do that. If it’s a LocalScript it should be game.Players.LocalPlayer.

Either way, your still getting the same player.

1 Like

It’s a bad practice. I really hope you don’t do that in your own code. And assuming he’s new to scripting, you’re teaching him bad habits.

3 Likes

Also thank you for giving me good practice :smiley:

2 Likes