I attempted to make a part that only one player can touch and be added to a table, and when he untouches the part he gets removed from that table.
But my code didn’t work and I don’t know the reason
Here’s my attempt:
01 | local team 1 = script.Parent.Team 1 |
03 | local maximum_ 1 = false |
05 | local team_table_ 1 = { } |
09 | local function onTouch(hit) |
11 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
13 | if not player then return end |
23 | table.insert(team_table_ 1 , player.Name) |
33 | local function onTouchEnded() |
35 | table.remove(team_table_ 1 , 1 ) |
41 | team 1. Part 1. Touched:Connect(onTouch) |
43 | team 1. Part 1. TouchEnded:Connect(onTouchEnded) |