trying to save the team a player is on and it won’t save
The Variable TEAM gets set once the player has a team
trying to save the team a player is on and it won’t save
what is the variable TEAM? It says its nil
i said the variable TEAM is The Players Team Once One Is Assigned
the line of code defining that? Why would you need to save a team anyway?
Okay, i see.
Can you provide the full script so i can help perhaps?
The error means the second argument you are passing in is missing or nil, since you are inputting the variable “TEAM” into the second argument it means it is not missing, but instead the value is nil. I suggest looking through your code and finding out why the value is nil, maybe use print statements to check the value of the TEAM variable before passing it into the SetAsync function.
This is because team doesn’t really exist in the other function, Is it because you commented it out? Because I see you did.
no, the commented out stuff is an attempt using stuff server storage but i just was lazy and didn’t remove it completely
Instead of using team, try using the result variable
Instead of using team, try using the result variable because the team is nil.
Wait im so blind sorry
if i use the result variable it won’t work if the player is joining for the first time and has no result
I suggest making a table, and putting in the each player who the randomteam()
got called on and instead of a global team variable, getting the team variable from that table instead.
can you give me an example? I’m a little confused on how to do what you are suggesting
Yeah i confused myself with how i formulated it.
So, 1) make a table, ex: local teamPlayers = {}
2) in the randomTeam
function, we will do something like: teamPlayers[plr] = randomTeam.Name
3) when saving, we do something like: local Team = teamPlayers[plr]
and then save that instead
it seemed like it worked but then i joined a different team so i don’t think it works
(To Know If It Works I Have To Get A Team And I Leave And Rejoin And Am On That Team At Least 5 Times In A Row Start of Testing To Finish)
Well, the result gives a name, you do
if result then
plr.Team = Teams:FindFirstChild(result)
end
it seems like it works but i keep getting this
can you copy and paste the script in here?
I want to test in studio