I was making two scripts, one that detects if a player is touching a part and if so adds them to a table, and the other is a round script that is supposed to teleport the players in the table but for some reason the round script doesn't detect the table? Here are the scripts (Both are server scripts, round script is in workspace and the part detection script is in a part which is also located in workspace)(Here is the script that detects the players touching the part):
PlayersTouching = {} local currentlytouching = true script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then currentlytouching = true local plr = workspace[hit.Parent.Name] --Access character from workspace. local player = game.Players:GetPlayerFromCharacter(plr) --Access (plr) local playernumber = #PlayersTouching + 1 table.insert(PlayersTouching, ""..playernumber.."", ""..plr.."") if PlayersTouching[""..playernumber..""] == ""..plr.."" then print(""..plr.."") wait until currentlytouching == false end end end) script.Parent.TouchEnded:Connect(function(hit) currentlytouching = false end)
Here is the round script:
local Pos local currentnum = 1 while wait() do game.ServerStorage.ElevatorValues.Easy.Intermission.Value = 65 for i = 1, 65 do wait(1) game.ServerStorage.ElevatorValues.Easy.Intermission.Value = game.ServerStorage.ElevatorValues.Easy.Intermission.Value - 1 end wait(1) map = game.Lighting.EasyMaps:GetChildren() mathrandom = math.random(1,#map) map = map[mathrandom]:clone() map.Parent = workspace Pos = map:findFirstChild("Spawn") for i = 1, #PlayersTouching do game.Workspace:findFirstChild(""..PlayersTouching.currentnum..""):moveTo(Pos.Position) wait() end wait(5) game.ServerStorage.ElevatorValues.Easy.EstimatedTime.Value = 30 repeat wait(1) game.ServerStorage.ElevatorValues.Easy.EstimatedTime.Value = game.ServerStorage.ElevatorValues.Easy.EstimatedTime.Value - 1 until game.ServerStorage.ElevatorValues.Easy.EstimatedTime.Value == 0 or game.ServerStorage.ElevatorValues.Easy.PlayersRemaining.Value == 0 map:remove() end
(The Round Script Spawns In The Map But Doesn't Teleport The Player And I Get This Error): Workspace.EasyRoundScript:15: attempt to get length of global 'PlayersTouching' (a nil value)
If you have any idea why this isn't working please let me know!