How would I make this work without LocalPlayer?

I need this to work without the LocalPlayer so it doesn’t have to be a Local Script but I can’t seem to get it to work without it
Code:

button = game.Workspace.Open.ClickDetector
plr = game:GetService("Players").LocalPlayer

button.MouseClick:Connect(function()
	if plr:GetRankInGroup(GroupIDInHere) >= 4 then
		game.Workspace.Door.CanCollide = false
		game.Workspace.Door.Transparency = 0.8
	end
end)

I just wrote GroupIDInHere in the GetRankInGroup because I don’t feel like sharing the Group’s ID right now

(K_reex’s reply is pretty much also the solution)

1 Like

I believe that the ClickDetector.MouseClick event passes a player argument

Here’s the documentation

4 Likes

If its a ClickDetector the Function first parameters is Player.

button = game.Workspace.Open.ClickDetector

button.MouseClick:Connect(function(plr)
	if plr:GetRankInGroup(GroupIDInHere) >= 4 then
		game.Workspace.Door.CanCollide = false
		game.Workspace.Door.Transparency = 0.8
	end
end)
2 Likes
  ClickDetector.MouseClick:Connect(function(player)
 -- essentially Local Player, if clicked that is
1 Like

I just tested and yes, the parameter is the player, consider marking K_reex post as the solution.