I can't find the players why did I go wrong?

why does it give me an error?

3 Likes

You need to get each player individualy

local Players = game:GetService("Players")

while wait(60) do
      for Player, in paris(Players:GetPlayers())
           Player.PlayerGui.ScreenGui.Frame.Se.LocalScript.Enabled = false
      end
end
3 Likes

you need to change paris to ipairs just sayin

6 Likes

Uploading: maomao.PNG…
it gives me the error in (in) what it is due to

1 Like
local Players = game:GetService("Players")

while wait(60) do
      for Player, in ipairs(Players:GetPlayers()) do
           Player.PlayerGui.ScreenGui.Frame.Se.LocalScript.Enabled = false
      end
end
3 Likes

Ahem
You tried to get the player through a Service which will obviously not work
If you want to get the localplayer, then you must define it first.

local Players = game:GetService("Players")
local Player = Players.LocalPlayer -- Player
2 Likes

Uploading: mao 2.PNG…
I always have the same problem with in

1 Like


it gives me the error in (in) what it is due to

1 Like
-- just do this instead

for i, Player in pairs(Players:GetPlayers()) do
     -- Code
end
1 Like

its because there is a comma between Player and in.
Use Verdancyx’s solution as this is fixed.

1 Like

no???
game:GetService(“Players”).LocalPlayer definitely works
you dont need to define players

What is blud talking about :skull:
Your code is the same thing as mine just shorter but messier. Players has other uses, not only LocalPlayer.

1 Like
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(plr)
	local PlayerGUI = plr:WaitForChild("PlayerGui")
	
	task.wait(1)
	PlayerGUI.ScreenGui.Frame.Se.LocalScript.Enabled = false
end)

youre saying that getting the player through a service wont work
but it definitely works, you dont have to define the players service to get the player

Never said that getting the player through a service doesn’t work, I made it into a variable so he can still use Players for other things, not just defining LocalPlayer only and also shortening code

If you think about it, it’s basically like defining an item with :WaitForChild() so you don’t have to keep calling :WaitForChild() whenever you wanna use it

1 Like

oh mb i misunderstood you

bruh

bruh this chat filter

1 Like

Well firstly, you used the Players service wrong, the players variable is only a service, to get the local player, you need to use players.LocalPlayer

Even if you can do that way, you still cant, because he is running the code in a server script. So it’s impossible. Well we could also wait for the player to join in, then obtain the player with the event, like this:

player = game:GetService("Players").PlayerAdded:Wait()

Hope this helps!