So, I have a huge invisible brick with CanCollide off around an area, and it's supposed to show the player a gui while they're in that area. However, whenever someone else enters the area, it removes the gui for anyone currently in the area. Any help?
--Hide the indicator
script.Parent.Transparency = 1
--The indicator was touched
script.Parent.Touched:connect(function(touching)
--Check if the part is part of a player
local player = game.Players:GetPlayerFromCharacter(touching.Parent)
if player then
--If the gui doesn't exist, make the gui
if player.PlayerGui:FindFirstChild("gangTurf") == nil then
local gui = game.ServerStorage.GuiStore.gangTurf:Clone()
gui.Parent = player.PlayerGui
script.Parent.TouchEnded:connect(function(newTouch)
--If the part that disconnected was from the receiving player, then remove the gui.
--Prevents weird flashing of the gui.
local checkPlayer = game.Players:GetPlayerFromCharacter(newTouch.Parent)
if checkPlayer == player then
gui:Destroy()
end
end)
end
end
end)

3 comments
Why not use http://wiki.roblox.com/index.php?title=API:Class/Player/DistanceFromCharacter and stop having lag?
What you could do to prevent the flashing of the gui by using debounce
You could save time and use magnitude.