I’ve ran into a very frustrating issue. I have a progress system that works for one player only, however many players are going to be playing in one map, so this won’t work. I don’t know where to go from here. Basically, I have a bunch of parts, that when touched, they increase the players’ progress. I don’t know how to proceed or if I should restart by doing something else. Thanks in advance for any help.
Basically, if a player touches the part, they will be added to the table. Unless the table already contains their name, they will gain a very small amount of progress, which should end up having their progress bar fill up to ~100%. The table check is so they can’t gain more than one point per brick. Note that it’s a server script.
local players = {}
local deb = false
local progressToAdd = 1 / #script.Parent.Parent:GetChildren()
script.Parent.Touched:Connect(function(p)
if p.Parent:FindFirstChild("Humanoid") then
if deb == false then
deb = not deb
if table.find(players, p.Parent.Name) == nil then
local val = game.Players[p.Parent.Name]:FindFirstChild("PlayerGui").ProgressTimer.ProgressBar.Config.Progress
val.Value = val.Value + progressToAdd
table.insert(players, #players + 1, p.Parent.Name)
end
deb = not deb
end
end
end)
Try adding a player variable in the function. I think you only made it so one person is added. I changed the table.insert line, because if you already have the players as a variable, they count as 1.
script.Parent.Touched:Connect(function(p)
if p.Parent:FindFirstChild("Humanoid") then
local Player = game.Players.LocalPlayer
if deb == false then
deb = not deb
if table.find(players, p.Parent.Name) == nil then
local val = game.Players[p.Parent.Name]:FindFirstChild("PlayerGui").ProgressTimer.ProgressBar.Config.Progress
val.Value = val.Value + progressToAdd
table.insert(players,Player) -- already inside the table lemme know if it doesn't work
end
deb = not deb
end
end
end)
Don’t think your modified table.insert would work either, wouldn’t it return a concatenation error? The second argument should be a number for the position in the table.