Is there a way to detect the player in no local script

if I do this for example its turning to a. is there a way to dectect the clicking player with a normal script

--script
script.Parent.MouseButton1Click:Connect(function(plr)
	--plr is turning to a because its a normal script
end)

The parameter “plr” is the player who clicked the part. Not sure what your question is.

1 Like

Theorically,

button:FindFirstAncestorWhichIsA("Player")

Should return the player. Not sure if it works 100% though, but is there a reason not to do it in a localscript?

Tell me if it dosent work

1 Like

Ok, I’II try. I let you know if it works or not

Or just script.parent all the way to the player (if the script is somewhere in player gui) but what blue said is probably just a easier and simpler way of doing that

1 Like

I believe that only works for click detectors

1 Like

There are couple of ways to get the Player :

--Click Detector
script.Parent.ClickDetector.MouseClick:Connect(function(Player)
  print(Player.Name)
end)


--Proximity Prompt
script.Parent.ProximityPrompt.Triggered:Connect(function(Player)
  print(Player.Name)
end)

--Touched a brick
script.Parent.Touched(function(Object)
  if Object:FindFirstChild("Humanoid") then
     print(Object.Parent.Name.."is a player!")
  end
end)


--local script
local Player = game.Players.LocalPlayer

[you can use remotes aswell.]





1 Like

Of course you can get the Player from MarketPlaceService aswell, and many more ways

1 Like

I actually used a textbutton but now I just added a Clickdetector with a textlabel. thanks for your help.

1 Like