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:
print(player.Name.. " has joined " ..team.Name) local resetBridge = true for _,rPlr in pairs(game.Players:GetChildren()) do if rPlr.TeamColor == plr.TeamColor and rPlr.Name ~= plr.Name then print("has teammates") resetBridge = false end end if resetBridge == true then print("reset bridge") local path = workspace.Paths:FindFirstChild(tostring(plr.Team)) if path then print("found path") path.Transparency = 0 path.CanCollide = true end 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.
local Teams = {} local Player = game.Players.LocalPlayer Player:GetPropertyChangedSignal("Team"):Connect(function() table.insert(Teams, Player.Team) print(Player.Name.." changed team to "..Player.Team) end)