Issue With getting player

I have this issue with the code bellow. I keep getting the wrong player not the one who execute the event.
Do you have any thoughts?

-- Local Script Part
-- Server Script Part
game.ReplicatedStorage.ev2.OnServerEvent:Connect(function(player, part)
-- Click Detector Part
function randomFunction(player)
		game.ReplicatedStorage.ev1:FireClient(player, self.clone.PrimaryPart)
1 Like

this feels like a troll post because of the obvious errors and unreasonable remoteevents unless you’ve had a sudden downgrade in coding ability since 2023…

you wouldn’t even be getting the wrong player because it’d error at self.parent


A) is self even defined here?

B) why are you listening for a mouse click inside of another function?



Those are the remote events not the main code. I get the wrong player when I execute my main code through the click detector, but the code is executing for other player not for the one executing it. Self is from oop I just put it as the example.


There are 2 remote event only as you can see


Don’t listen for a mouse detector click in the function, it will cause issues like the one you are describing. Move it outside of the other functions, it passes the player that clicked it as a parameter anyway.

Please don’t use self as an example variable here, unless you are actually doing OOP - it’s kind of confusing and misleading, I thought you were using a module for a second.


I am cloning some objects and each object has a click detector inside. I was forgetting to pass into the click detector the player argument. Now its working :slight_smile: Thanks!

Actually I am using a module for both the click detector and the event from server side. I just commented above each code snippet what it is and I never said that the whole code is in one script. :slight_smile:

Apologies, you never said you were using a module and I had no way to tell except from self, which you said was an example.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.