Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i store player data with out repeating, and reset values when they leave?

Asked by
L3xie 0
5 years ago

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.

0
wait() should NOT be a condition in while loops. User#19524 175 — 5y
0
I'm super confused now cause the roblox wiki said i could... L3xie 0 — 5y
0
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 maumaumaumaumaumau 98 — 5y

Answer this question