You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear! I want to learn more about scripting
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.
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:
Listen for the BasePart.TouchEnded event
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