I'm trying to get the the Players Name, UserId, and any other data I might need throughout the game. I've tried multiple different approaches, now I'm trying putting a local script in the players that sends this data to a folder in workspace.
local Dataz = game.workspace.Data.MWData
local Players = game:GetService("Players")
while wait() do
if Dataz.HG1.Toggle.Value == false then
Dataz.HG1.Player.Value = Players.LocalPlayer.Name
Dataz.HG1.Avatar.Value = Players.LocalPlayer.UserId
Dataz.HG1.Toggle.Value = true
end
end
while wait() do
if Dataz.HG1.Toggle.Value == true then
Dataz.HG2.Player.Value = Players.LocalPlayer.Name
Dataz.HG2.Avatar.Value = Players.LocalPlayer.UserId
Dataz.HG2.Toggle.Value = true
end
end
the problem is it works great for the first player who enters the game but not for the second. I wanted to have this script fire when the player joins the server and then destroy itself, but I need these values to reset themselves when the player leaves, does anyone have any pointers or things I should research to do this.

3 comments
wait() should NOT be a condition in while loops.
I'm super confused now cause the roblox wiki said i could...
incapaz stop saying that , it does a loop when a miliseconds pass, preventing the script to do a loop per 0 seconds, if used while true it would do a timeout error