Script does not destroy StringValue?
Hey there. I am creating a script where all players that are in the game get listed. If someone leaves or gets killed from the game the StringValue gets destroyed. Now, I am doing the Player Leave thing, but the script does not destroy the StringValue.
01 | game.Players.PlayerRemoving:Connect( function (player) |
02 | local PlayerFolder = workspace.GameD |
03 | local PlayerName = player.Name |
04 | PlayerFolder:WaitForChild(PlayerName):Destroy() |
05 | local AllPlayer = workspace.AllPlayer |
06 | local PlayerCount = workspace.GameD:GetChildren() |
08 | for i, user in ipairs (PlayerCount) do |
09 | local CompleteName = "User" .. NumberA |
10 | if AllPlayer:WaitForChild(CompleteName).Value = = PlayerName then |
11 | AllPlayer:WaitForChild(CompleteName):Destroy() |
When the game starts, every player will get their StringValue. Like "User0", "User1" till User9.
The players are counted by created StringValues when they joined.
"Every player gets StringValue at game start"
01 | local PlayerCount = workspace.GameD:GetChildren() |
05 | for i, user in ipairs (PlayerCount) do |
06 | local PlayerFile = Instance.new( "StringValue" ) |
07 | PlayerFile.Name = "User" .. NumberC |
08 | PlayerFile.Parent = workspace.AllPlayer |
09 | PlayerFile.Value = user.Name |
11 | print (PlayerFile.Name) |
12 | print (PlayerFile.Value) |
"Every Player who joins gets StringValue"
1 | game.Players.PlayerAdded:Connect( function (player) |
2 | local PlayerFolder = workspace.GameD |
4 | local PlayerSave = Instance.new( "StringValue" ) |
5 | PlayerSave.Name = Player 2. Name |
6 | PlayerSave.Parent = PlayerFolder |