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:
local team1 = script.Parent.Team1 local maximum_1 = false local team_table_1 = {} local function onTouch(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if not player then return end if not maximum_1 then maximum_1 = true while true do wait(hit) table.insert(team_table_1, player.Name) print'added' end end end local function onTouchEnded() table.remove(team_table_1, 1) print'removed' end team1.Part1.Touched:Connect(onTouch) team1.Part1.TouchEnded:Connect(onTouchEnded)
:Remove is deprecated and even using :Destroy you are only removing the element so it cant be detected again. What I would do is parent it in replicated storage then a wait() method and then add it back so it can detect it. Computers need time to think!