|
| 31 Jul 2017 09:00 PM |
I have a script that's supposed to open a shop when you touch the front of the shop, but how do I get it to open when the player gets x studs away from it and then close when they leave it?
Current Script:
function OnTouch(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) local GUI = player.PlayerGui:FindFirstChild("All_GUIS") if player and GUI then player.PlayerGui.All_GUIS.Shop_GUIS.Shop.Visible = true player.PlayerGui.All_GUIS.Close.Visible = true
end end script.Parent.Touched:connect(OnTouch)
|
|
|
| Report Abuse |
|
|
|
| 31 Jul 2017 09:02 PM |
Remember that a GUI on the screen is done on the client because the StarterGUI will be cloned into the player; therefore, any changes done on the server cannot be done on the client.
https://www.youtube.com/watch?v=dQw4w9WgXcQ |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2017 09:06 PM |
| I can figure out the latter; your answer doesn't answer my question. |
|
|
| Report Abuse |
|
|
JoeDev
|
  |
| Joined: 04 Oct 2011 |
| Total Posts: 6475 |
|
|
| 31 Jul 2017 09:07 PM |
you can used ontouch with noncan collide transparent walls that disable the shop gui when touched
these can be placed around the shop in a geometric fashion |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2017 09:09 PM |
| It's there not something like Magnitude or GetPartsInRadius-like function to make it easier? |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2017 09:13 PM |
imperialthinking did answer the question
if this is being done on the server but you want the client to see it then this won't work
i personally recommend having the GUI stored in the player with a localscript that contains a function that is bound to a remote event that the server would fire
|
|
|
| Report Abuse |
|
|
|
| 31 Jul 2017 09:17 PM |
| magnitude should work for what you're trying to do though worst case scenario invisible parts could be an easy way to create something that feels similar |
|
|
| Report Abuse |
|
|