I'm making a pixel art game where you can disable other players from coming to where you draw. What I'm trying to do is detect a player's previous team, so that I can make their bridge able to collide again if they have no teammates. Here's a bit of my script:
01 | print (player.Name.. " has joined " ..team.Name) |
02 | local resetBridge = true |
03 | for _,rPlr in pairs (game.Players:GetChildren()) do |
04 | if rPlr.TeamColor = = plr.TeamColor and rPlr.Name ~ = plr.Name then |
05 | print ( "has teammates" ) |
06 | resetBridge = false |
07 | end |
08 | end |
09 | if resetBridge = = true then |
10 | print ( "reset bridge" ) |
11 | local path = workspace.Paths:FindFirstChild( tostring (plr.Team)) |
12 | if path then |
13 | print ( "found path" ) |
14 | path.Transparency = 0 |
15 | path.CanCollide = true |
16 | end |
17 | end |
It prints when a player joins a team, but the problem is that it only picks up the new team when it tries to make the path able to collide.
it's either you store it in a data store or store it in something else, like an object value or string value,
so every time they change a team, it's stored, and when they join the game, the team they are in is stored.
I got no scripts tho
You will need to store it inside of a table.
1 | local Teams = { } |
2 | local Player = game.Players.LocalPlayer |
3 | Player:GetPropertyChangedSignal( "Team" ):Connect( function () |
4 | table.insert(Teams, Player.Team) |
5 | print (Player.Name.. " changed team to " ..Player.Team) |
6 | end ) |