b = script.Parent
function onTouched(plr)
game.Players.LocalPlayer.Team = game.Teams["Blue"]
end
b.Touched:connect(onTouched)
I assume in this case, b would be a part.
When a part is touched, the hit is not the actual player, but a limb of the model of the player in the workspace.
So you end up with
01 | b = script.Parent |
02 |
03 | function onTouched(hit) |
04 | name = hit.Parent.Name --storing the name of the player you hit |
05 | for i,v in pairs (game.Players:GetChildren()) do --finding the player in game.Players |
06 | if v.Name = = name then |
07 | v.Team = place in the team |
08 | end |
09 | end |
10 | end |
11 |
12 | b.Touched:connect(onTouched) |
You cannot access LocalPlayer in a ServerScript. The reason it works in studio is because it only has one player, but with servers, they have multiple players. So the server script is just like "What player am I supposed to choose?!" Also, you should use code blocks when displaying code.