Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make click detector work with filtering enabled?

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?

5 comments

0

Should I expect an answer xD Maybe you just can't. If you can't let me know guys :P

0

 Building games with FE is hard at first but once you learn it you will have opened a world of possibilities

1

I am working on an answer for this but I want to test it so that I know it will work.

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

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.

3 answers

✓ Accepted answer

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.

1 comment

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.

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!

1 comment

0

Good idea because other people may read this in the future :3

This discussion is preserved as it was. New answers, comments, and votes are closed.