Gearshop gui closed button

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear! I want to learn more about scripting

  2. What is the issue? Include screenshots / videos if possible! I want make the gearshop gui close after leaving the part like when I touch it it open and when I leave the part it closed without pressing the x button.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? I try a lot of thing I tried to moved the script around a little bit but it still doesn’t work.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

It’s not really clear what you want us to do, but I assume that you want to close the GUI when a player stops standing on a part.
To do it you would either:

  1. Listen for the BasePart.TouchEnded event
  2. Check the magnitude between the player and the part (best option)

I recommend you to go with 2. since touch events are a bit bad for this.

    if (Part --[[ replace with the part]].Position - character --[your player's character]].PrimaryPart.Position).Magnitude >= 20 --[[replace with any number you want]] then
         -- Your code to close the GUI
1 Like

I haven’t tested it but it should work.

Thank you so much ima test it out

Do I have to change part the the name of my part?

Yes, of course! :smiley: If you can’t script well I suggest you to watch TheDevKing’s beginner and advanced tutorial series. It helped me a lot.