It's kinda hard for me to ask the question than to explain it. So I am working on a spectating gui and the way it works is the localscript only goes up by 1. In the replicated storage there is a folder named "PlayerList" which has ObjectValues, the names of the values are a number although when a player dies they are removed from the list. This causes gaps in the PlayerList. For instance there are 3 players. So there are 3 ObjectValues inside the PlayerList folder. Player 2 dies making the folder have 2 values named "1" and "3". Now when a player ties to go from "1" to "3" my script won't work because it will try to find "2" which is nil.
Script:
local bttn = script.Parent local currentSpec = bttn.Parent.Spectating local playerList = game.ReplicatedStorage.Game.PlayerList local sounds = game.ReplicatedStorage.Sounds bttn.MouseButton1Click:Connect(function() --Clicked if currentSpec.Value == playerList.Reserve.Value then else sounds.Click:Play() currentSpec.Value = currentSpec.Value + 1 --Heres the problem. end end)
I don't quite know how effective this will be.
Try This:
for i,v in pairs(playerlist:GetChildren()) do v.Name = i end
Hope This Helped!