Hover GUI Problem


#1

Hello there,

I have my own door that opens on key. And you have to hover your mouse over in order for it to open, however I have this problem where when I hover over the UI then open the door, the UI is still on my screen. Does anyone know how to fix this?


The issue ^

If you want to take a look at the scripts here is the door:

File

DoorFile.rbxm (17.3 KB)

Please don’t take for your own personal use.


#2

Hypothesis:
Since you’re sending information over the client <> server boundary, events will not be received instantaneously. That slight delay is enough for users to hover > leave > hover, which would lead to a second event to clone the GUI while still trying to send information to the client about the first one.

Question:
Are you familiar with CollectiveService? What you can do is serialize the door objects found in your game then iterate through the list of doors to be interacted with. That way you can use one snippet of code instead of copy and pasting.


#3

How would I set up the CollectiveService?


#4

It’s CollectionService, btw.


#5

Do you know how I would set this up? I included the door file in the description.


#6

Working on it for ya. @Wrathsong great catch, I realized this the moment I went back to reference the service.


#7

Whoops, it’s called CollectionService, not CollectiveService.

The use of the service is pretty straightforward, the service utilizes what is called Tags. These tags act as containers or the way I see it, a table filled with objects.

To assign an object to a tag, you’ll need to get the service first. Easy enough right?

local CollectionService = game:GetService("CollectionService")

Then, we’ll need to define a tag for all the doors. For simplicity, we will just use “Doors”

CollectionService:AddTag(doorObject, "Doors") --Object, Tag

The beauty of this service is if you serialize all of your objects in the studio you will only have to do this once. It will persist on newly created place servers. So let us say we create a folder of all the doors, that way we can efficiently iterate through them all.

local CollectionService = game:GetService("CollectionService")
local doorFolder = workspace.Doors
for _, currentDoor in pairs(doorFolder:GetChildren()) do
   CollectionService:AddTag(currentDoor, "Doors") -- will then take the current door and put it under the Doors Tag.
end

Alternatively you can just paste this in the command bar. and it will serialize them.

for _, currentDoor in pairs(workspace.Doors:GetChildren()) do
   game:GetService("CollectionService"):AddTag(currentDoor, "Doors")
end

My time on the internet is very limited so I’ll just send you the place file I have.
Doors.rbxl (29.8 KB)

It still doesn’t address your UI cloning issue. :frowning:


#8

Thank you very much, I appreciate it. It’s fine if you couldn’t fix the UI cloning issue. I will have to make a separate post about it.