Assistance with Line 32

Ok, so. What an Inconvenience for this to happen while the game physics are smooth and exquisite. I, played run the game for Line 32 to appear as an Error. As a Programmer, I was completely clueless as to what the error was. any of you know what the problem is here?


Game:
image

1 Like

Maybe this will help you?

local p = players:GetPlayers()
3 Likes

players.getPlayers should be players:GetPlayers()

1 Like

The current way you are doing it is kinda inefficient, since you are using a for loop to go through numbers instead of a table, below is the code that you can replace that with to make this a bit simpler.

But with the error, the only thing I know it could be is the improper capitalization. Its :GetPlayers() instead of .getPlayers.

transceiver.OnServerEvent:Connect(function(player, data)
     for i,v in pairs(game.Players:GetPlayers()) do
          if v.Name ~= player.Name then
             local Info = {player.Name, data}
             transceiver:FireClient(v, info)
          end
     end 
end)
1 Like

So, the problem is capital letter issue, understand now thanks y’all

Not just that, it’s a function called with a colon operator. When you call a function of a table/whatever with a colon, it’s the equivalent to calling that function with the table/whatever as the first argument. This means that players:GetPlayers() is the same as players.GetPlayers(players).

2 Likes

I am not understanding, your getting the players twice?

Doing table:someFunction(whatever) (colon notation) is the same as doing table.someFunction(table, whatever). The link I posted explains more.

1 Like

Alright, thanks you. I am just trying to figure it out because, the game concept is an FPS game. When the player loads in they don’t load at the specific spawn point given. Looking back at the script there was an error and I had no clue as to what it was. So, I appreciate this guidance and help on my behalf! God bless you.

1 Like

Since you are getting the players it cant be .getPlayers because of many reasons. One it must have a colon because it is called with a colon operator. Second because G must be capital.

  • Its called with a colon
  • G must be capital

For instance,

local p = players:GetPlayers()

1 Like

We’ve gone over that in previous post, but thank you for contributing means a lot.

1 Like

If you don’t understand than I will explain. When we say game.Players we are defining the player service which stores all the players. :GetPlayers() gets all the players in the service.

1 Like

Yes. i understand that. It’s the colon function that cut me off.

1 Like