Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to get MouseHoverEnter to work with Filtering?

Asked by 9 years ago

I am having trouble with filtering enabled getting in the way. We're not exactly worrying about how to get remote events to work, but how I should find a way to do this. Let me explain this the best I can.

I am making a DayZ type of game. The problem I am running into at the moment is with loot. With the type of game in mind, we all should be aware that there will be hundreds of the same time of loot on the map, for example, beans. Remembering this, let's continue.

I am using ClickDetector's "MouseHoverEnter" API as a way for gui text to pop up to give you the option to "Take Beans" (or any other loot). That's not important. The part that makes this tough is that the script to do this all has to be inside the actual loot part. Here is the print filter's output with having a script inside the loot part (in a server script):

Filtering is enabled. Event MouseHoverLeave for instance Workspace.Beans.Loot.ClickDetector will not be replicated.

Is there a way around this? The script has to be in the part, because there will be hundreds of "Beans". Another way would be to have a local script in something like PlayerGui, and have it directly do game.Workspace.Beans, but remember there will be hundreds of Beans, and would cause the script to error and break.

Another important part is that I need to be able to use .MouseHoverEnter:connect(function(Player) somehow. With having the 'Player' argument, I can do all the duties of transferring the loot's properties to a players backpack.

Thanks to anyone who can help. If you need more clarification just ask.

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

Putting a script inside every single bean in the Workspace to correspond with it's ClickDetector will cause massive amounts of lag and is extremely inefficient. Use a LocalScript in PlayerGui to detect if the mouse's Target is named 'Beans'. One script to replace potentially hundreds, and you won't have a problem with FilteringEnabled getting in the way of your ClickDetectors.

Example;

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

while wait(.5) do --.5 interval to reduce lag
    if mouse.Target ~= nil then
        if mouse.Target.Name == "Beans" then
            --Your code here--
        end
    end
end
0
I used Mouse.Target before using MouseHoverEnter. I switched over to MouseHoverEnter whenever I found it, because using Mouse.Target is really buggy. I'm also aiming for it to instantly show up, not even 0.5. Regardless, I suppose this is the only apparent option I have with my set of circumstances. AntiFiter 5 — 9y
0
How badly would it lag? AntiFiter 5 — 9y
0
Well, if like you said hundreds of brean models. Each with a script and clickdetector. Then you have to think about how many players are in the server. And how many other objects to pick up.. this is your only option. Try making the hitbox for the beans bigger so it's easier for the mouse to target them if that's a problem. Goulstem 8144 — 9y
Ad

Answer this question