This is my peace of code I am trying, to make the team 'Test' Removed When 1 Player enters the game but there is an Error for it.
while true do if game.Players.NumPlayers == 1 then game.Teams.Test:remove end -- This one says "function arguments expected near 'end' " end
Anyone able to explain this to me?
First of all, that piece of code would crash the game because you are not allowing the thread scheduler to move on with other threads. You need to add wait() to yield the current thread so the game knows it can move on with other actions.
The error tells you that the interpreter was expecting a function call. Remove is a method you are not calling. Also, Remove is deprecated, consider using Destroy instead.
while wait() do --We add a call to wait to yield the thread if game.Players.NumPlayers == 1 then game.Teams.Test:Destroy() --We call the method with () end end
Consider optimizing your code, since you would be running an infinite loop and wasting resources on something that can be solved with events.
I am trying to make the team 'Test' Removed when 1 Player enters the game.
game.Players.PlayerAdded:connect(function() game.Teams.Test:Destroy() end)
you need a function loop
function nameofcodehere() if game.Players.NumPlayers == 1 then game.Teams.Test:remove() -- or Destroy() end end