I am trying to make a script that changes the team of the player when they click a button but I keep getting this error and I don’t know how to fix it.
.OnServerEvent connections always receive the instance of the player who sent the remote event as its first parameter. That means you don’t need to fire game.Players.LocalPlayer instance yourself, simply fire “team,” and have the server event’s parameters set to player, team as player will always be the first parameter listed.
Anywhere else in your localscript that may be changing what team equals? Your exact snippet worked for me so it may be a problem exterior to it. Is team also declared as a local variable somewhere above? i.e. local team = nil
The only thing I could think of is that I have like 4 other scripts that allow for team change with the same script (with checking if user is in a group)
Whats actually happening is you’re tyring to get a child of an Instance with an Instance (which isn’t allowed), Instance[k] will only work if k is a string, and since you’re sending the Team object directly without getting it’s Name, it throws this error.