Can somebody help me? For some reason when my character walk to a different position the "Shop GUI" isn't showing up. It's a script that made a GUI show up when a player walk near to the brick but it doesn't work if I change my character position. How come? Can you guys help me?
local part = script.Parent
local Distance = 8 -- 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

4 comments
I tested out your script with a part, a 'ShopGui' and this exact script inside of it, and it worked fine. Are you sure it's not working? Maybe you just have the script disabled?
If Filtering Enabled is enabled, it won't work.
@Warfaresh0t I thought that too originally, but I tested it with FilteringEnabled, and it worked...
Yeah, It's work guys. I'm sorry >w< But there's one problem though. If I use while true do, it is bad for my game? Cause I hear many developers say that it can cause lag to the game if I use while true do, is that true?