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.)
local RanksAllowed = {team1,team2,team3} local debounce = false local team1 = game.Teams.Team1 local team2 = game.Teams.Team2 local team3 = game.Teams.Team3 print(RanksAllowed[2]) script.Parent.Touched:Connect(function(hit) if hit.Parent.Humanoid ~= false then local function findPlayerTeam(player) local player = player print(player.Team) end if findPlayerTeam(hit.Parent).Team == RanksAllowed then print("duck, quack quack") end end end)
local Players = game:GetService("Players") local part = script.Parent local RanksAllowed = {game.Teams.Team1, game.Teams.Team2} local function onTouched(part) local player = Players:GetPlayerFromCharacter(part.Parent) if not player then return end for i,v in pairs(RanksAllowed) do if player.Team == v then print("Player is on the right team") end end end part.Touched:Connect(onTouched)
problem: RanksAllowed was a table so it wasn't getting team names