This code works fine but the problem I get is when I touch the part that triggers the function, it sometimes flashes the GUI (by that i mean the gui is being repeatedly showing and stop showing itself for a while)
I notice it happens on the edges of the part that triggers the function.
Code Below:
function touch(hit)
if game.Players:findFirstChild(hit.Parent.Name) ~= nil then
player = game.Players[hit.Parent.Name]
if player.PlayerGui:findFirstChild("ShopSetupGUI") == nil then
gui = script.ShopSetupGUI:clone()
gui.Parent = player.PlayerGui
end
repeat
wait()
until (player.Character.LeftFoot.Position - script.Parent.Parent.Pad.Position).Magnitude > 8
gui:Remove()
end
end
script.Parent.Parent.Pad.Touched:Connect(touch)

1 comment
I think you need a debounce