I have a script that will print something if a part is stepped on. The object has to have a humanoid to make sure it's a player, and the player has to be on the right team to print it. Here it is, can someone please point out the errors and how to fix it? It won't work (of course.)
01 | local RanksAllowed = { team 1 ,team 2 ,team 3 } |
02 | local debounce = false |
03 |
04 | local team 1 = game.Teams.Team 1 |
05 | local team 2 = game.Teams.Team 2 |
06 | local team 3 = game.Teams.Team 3 |
07 | print (RanksAllowed [ 2 ] ) |
08 | script.Parent.Touched:Connect( function (hit) |
09 | if hit.Parent.Humanoid ~ = false then |
10 | local function findPlayerTeam(player) |
11 | local player = player |
12 | print (player.Team) |
13 | end |
14 | if findPlayerTeam(hit.Parent).Team = = RanksAllowed then |
15 | print ( "duck, quack quack" ) |
16 | end |
17 | end |
18 | end ) |
01 | local Players = game:GetService( "Players" ) |
02 | local part = script.Parent |
03 | local RanksAllowed = { game.Teams.Team 1 , game.Teams.Team 2 } |
04 |
05 | local function onTouched(part) |
06 | local player = Players:GetPlayerFromCharacter(part.Parent) |
07 | if not player then return end |
08 | for i,v in pairs (RanksAllowed) do |
09 | if player.Team = = v then |
10 | print ( "Player is on the right team" ) |
11 | end |
12 | end |
13 | end |
14 | part.Touched:Connect(onTouched) |
problem: RanksAllowed was a table so it wasn't getting team names