--// variables //-- local debounce = false local placement = script.Parent.Parent.Values.Placings local amount = game.ReplicatedStorage.Values.Amount local finished = {} local finishedplrs = {} --// touched script //-- script.Parent.Touched:Connect(function(hit) if debounce == false then debounce = true if hit.Parent:FindFirstChild("Humanoid") then if game.Players:FindFirstChild(hit.Parent.Name) then local plr = game.Players:FindFirstChild(hit.Parent.Name) if plr.TeamColor == BrickColor.new("Dusty Rose") then print(plr.Name) for i, v in pairs(finishedplrs) do if v.Name == plr.Name then print(plr.Name .. " already finished.") else table.insert(finished, 1, plr.leaderstats.Team.Value) table.insert(finishedplrs, 1, plr.Name) print(finished[1] .. " - " .. finishedplrs[1]) end end local debounce = false end end end end end)
print(plr.Name)
works (line 16) but
print(finished[1] .. " - " .. finishedplrs[1])
doesn't work. (line 23)
Alright, I fixed it. Firstly, I completely forgot that in pairs() loops only loop for how many things are in a table. So first, I check whether something's inside. If it isn't there, it adds it in. If something Is there, it will check if it was already there. If not, then it will insert it in.
for i, v in pairs(finishedplrs) do print("Checking player: " .. plr.Name) if v.Name == plr.Name then print(plr.Name .. " already finished.") else table.insert(finished, 1, plr.leaderstats.Team.Value) table.insert(finishedplrs, 1, plr.Name) print(finishedplrs[1] .. ": " .. finished[1]) end end else table.insert(finished, 1, plr.leaderstats.Team.Value) table.insert(finishedplrs, 1, plr.Name) print(finishedplrs[1] .. ": " .. finished[1]) end