I'm having trouble with this:
1 | game.Players.PlayerAdded:connect( function (player) |
2 | if player.Teams = = Spectators then |
3 | player.CameraMode = "LockFirstPerson" |
4 | end |
5 | end ) |
Thanks in advance!
01 | function getTeamsColorFromName(name) |
02 | local color |
03 | for _,v in pairs (game.Teams:GetChildren()) do |
04 | if v.Name = = name then |
05 | color = v.TeamColor |
06 | end |
07 | end |
08 | return color |
09 | end |
10 |
11 | game.Players.PlayerAdded:connect( function (player) |
12 | repeat wait() until player ~ = nil -- This event is not very trust-worthy. |
13 | if player.TeamColor = = getTeamColorFromName( "Spectators" ) then |
14 | player.CameraMode = "LockFirstPerson" |
15 | end |
16 | end ) |
Broken down, the function at the top returns the Team's TeamColor from the name of it (Spectators) and then sets their CameraMode.
1 | game.Players.PlayerAdded:connect( function (player) |
2 | if player.Teams = = "Spectators" then |
3 | player.CameraMode = "LockFirstPerson" |
4 | end |
5 | end ) |
That should work? I can't test it, RobloxStudio crashes every 1 minute for me.