Note: I’m not requesting for a script but an idea of how to do it. Also, although my script works, it can be pretty buggy when showing guis.
I’ve recently made a on touch of a welded object, you can press e to pick up script. However, this script is pretty buggy as seen when the billboard GUI which shows the press e image label on touch can appear and disappear a few times before showing the GUI. This is possibly due to roblox’s touch event being highly buggy and not detecting correctly. Thus, may I ask of a much less buggy way to detect touched and touch ended such that the billboard GUI will not flash and disappear multiple times. I’m pretty sure there is a way to do such as the top games do not appear to have such flashing problem. Some examples would be Flee the facility whereby when you are close to the computer it will just show a screen GUI image label without showing flashing when you are close. I use roblox’s touched event for detecting touch of the object and magnitude which is much better than roblox’s buggy touch ended. However, it still doesn’t solve the problem fully. So is there a efficient way to detect touch without activating touch ended?
I'm assuming you've enabled Filtering as it's way easier since it's all local and other's can't see the change you're making to the GUI.
I think the most efficient way to do it is this.
Local Script in StarterGear
local plr = game.Players.LocalPlayer local interactDistance = 5 --Customisable local canInteract = false local interactables = {workspace.Interactable} --Add or remove blocks repeat wait() until plr.Character ~= nil local char = plr.Character game:GetService("UserInputService").InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.E and canInteract = true then --All code inside here will run when the player has pressed the specified key and is closer than the distance required for the GUI to be visible end end) while wait() do for i, part in pairs(interactables) do if (part.Position - char.Torso.Position).magnitude < interactDistance then canInteract = true --Turn GUI On else canInteract = false --Turn GUI Off end end end
I truly hope this has helped!