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

How to make click detector work with filtering enabled?

Asked by 8 years ago

So when using a click detector with filtering enabled on the click detector doesn't return the player who clicked it. Here's my code,

script.Parent.ClickDetector.MouseClick:connect(function(plr)
   print(plr)
end)

The output would be nil when testing this on a server. How would you get the player? I've tried using remote events but obviously I can't get the player so that failed. Is there another way of getting the player or am I just doing something wrong?

0
Should I expect an answer xD Maybe you just can't. If you can't let me know guys :P User#11440 120 — 8y
0
 Building games with FE is hard at first but once you learn it you will have opened a world of possibilities AZDev 590 — 8y
1
I am working on an answer for this but I want to test it so that I know it will work. AZDev 590 — 8y
0
It's inside a part with a click detector in the workspace. This is a regular script. I know you can get the player from a touched event so I'm sorta confused on why you can't with a click detector. TheDoubleJ0Jake0Jam User#11440 120 — 8y
0
I will try my best to answer this question soon however I have English class rn and I need to get to a laptop to answer it so I will have to wait for another period and lunch to pass before gaining access to a laptop but, I will try my best to answer it. KingLoneCat 2642 — 8y

3 answers

Log in to vote
0
Answered by
AZDev 590 Moderation Voter
8 years ago

ClickDetectors do work in FE. For some reason I can't get print statements to print.

If you want to for example give the player a tool when he clicks you need to use a remote event to access the players backpack.

Remote events should be stored in ReplicatedStorage.

If you are giving the player a tool you would do

ServerScript

script.parent.ClickDetector.MouseClick:connect(function(player)
    game.ReplicatedStorage.RemoteEvent:FireClient(player)
end)

Now on the players side you would need to have a listener for the client event. LocalScript

function name()
    -- The code that gives the player said tool
end

game.ReplicatedStorage.RemoteEvent.OnClientEvent:connect(name)

You can read more on events here: RemoteEvents

Make sure you scroll down to the see also section and read those too.

That will be a big help when you are building your FE game.

Hope this helped.

0
Yeah, that might work. I'll try that as soon as I get home which is in... Oh, six and a half hours. Thanks for your help though. I did try something similar. I'm trying to play a sound that's within a player when the button is clicked. I'll try this though. Thanks. User#11440 120 — 8y
Ad
Log in to vote
0
Answered by 6 years ago

I just want to necrobump this, this is so simple. Sorry! The answer is, that you're printing a "object" to the console. Remember to always put it like this while printing it to the console

print(plr.Name)

Yet, sorry!

0
Good idea because other people may read this in the future :3 THEROBLOXAIN2 15 — 6y
Log in to vote
0
Answered by 5 years ago

Do they also work with the old Roblox physics?

Answer this question