Can somebody help me? I don't want my GUI to show up when someone pass by the wall. Like for example; a brick I'm using that has a GUI in it and if someone or me walk near to it, it will pop up a shop GUI. And it work just fine but I want it to not show the GUI when someone walk by the wall. It also sometimes doesn't work if I move my character to a different position. If I move it to the left side of the brick, the GUI doesn't show up and I have to come very close to it but if I stand on the front side, then the GUI show up immediately. Any ideas why this is happening?
Here's an image to see what I'm talking about:
https://gyazo.com/6b753d905ff6721ec02222ea3488ec9b
Here's my layout, please check them:
https://gyazo.com/bf52b9c9d36b726b2cd84416da06bc5c
Also, here's the script that make the Shop GUI show up (This is a regular script not local):
local part = script.Parent
local Distance = 20 -- The distance in studs a player can be from the shop part and activate the shop
while true do
wait()
for i, v in ipairs(game.Players:GetPlayers())do
if v.Character ~= nil then
local Character = v.Character
local Torso = Character:FindFirstChild('Torso')
if Torso then
local Magnitude = (part.Position - Torso.Position).magnitude
if Magnitude <= Distance then
local HasTag = v.PlayerGui:FindFirstChild('ShopGui')
if not HasTag then
local CreateTag = part.ShopGui:Clone()
CreateTag.Parent = v.PlayerGui
end
else
local HasGui = v.PlayerGui:FindFirstChild('ShopGui')
if HasGui then
HasGui:Remove()
end
end
end
end
end
end
As always, thank you for helping me.
