I have these values that are put in a folder in ServerStorage called Players. From there I have a datastore that gives them values. If they were to change, how would I get the Text to change whenever that value changes?

LocalScript:

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Stats = PlayerGui:WaitForChild("Stats")
local StatsFrame = Stats:WaitForChild("Frame")

--Folders--
local Player1Folder = StatsFrame:WaitForChild("Player1")
local Player2Folder = StatsFrame:WaitForChild("Player2")
local Player3Folder = StatsFrame:WaitForChild("Player3")
local Player4Folder = StatsFrame:WaitForChild("Player4")
local Player5Folder = StatsFrame:WaitForChild("Player5")
local Player6Folder = StatsFrame:WaitForChild("Player6")
local Player7Folder = StatsFrame:WaitForChild("Player7")
local Player8Folder = StatsFrame:WaitForChild("Player8")

--PlayerText--
local Player1Text = Player1Folder:WaitForChild("Player1")
local Player2Text = Player2Folder:WaitForChild("Player2")
local Player3Text = Player3Folder:WaitForChild("Player3")
local Player4Text = Player4Folder:WaitForChild("Player4")
local Player5Text = Player5Folder:WaitForChild("Player5")
local Player6Text = Player6Folder:WaitForChild("Player6")
local Player7Text = Player7Folder:WaitForChild("Player7")
local Player8Text = Player8Folder:WaitForChild("Player8")

local AddPlayerEvent = game:GetService("ReplicatedStorage"):WaitForChild("AddPlayer")

AddPlayerEvent.OnClientEvent:Connect(function()
	if Player1Text.Text == "" then
		Player1Text.Text = Player.Name
	elseif Player2Text == "" then
		Player2Text.Text = Player.Name
	elseif Player3Text == "" then
		Player3Text.Text = Player.Name
	elseif Player4Text == "" then
		Player4Text.Text = Player.Name
	elseif Player5Text == "" then
		Player5Text.Text = Player.Name
	elseif Player6Text == "" then
		Player6Text.Text = Player.Name
	elseif Player7Text == "" then
		Player7Text.Text = Player.Name
	elseif Player8Text == "" then
		Player8Text.Text = Player.Name
	end
end)

Server Side Script:

local SS = game:GetService("ServerStorage")
local Players = SS:WaitForChild("Players")

local AddPlayer = game:GetService("ReplicatedStorage"):WaitForChild("AddPlayer")

Players.ChildAdded:Connect(function()
	AddPlayer:FireAllClients()
end)

Data Store:

local DataStore = game:GetService("DataStoreService"):GetDataStore("TA5970AJ3B")

local ServStorage = game:GetService("ServerStorage")
local Players = ServStorage:WaitForChild("Players")

game.Players.PlayerAdded:Connect(function(player)
	
	local Namee = Instance.new("Folder", Players)
	Namee.Name = player.Name	
	
	local folder = Instance.new("Folder", Namee)
	folder.Name = 'Stats'
	
	local pts = Instance.new("IntValue", folder)
	pts.Name = 'Points'
	pts.Value = 0
	
	local ast = Instance.new("IntValue", folder)
	ast.Name = 'Assists'
	ast.Value = 0
	
	local reb = Instance.new("IntValue", folder)
	reb.Name = 'Rebounds'
	reb.Value = 0
	
	local steal = Instance.new("IntValue", folder)
	steal.Name = 'Steals'
	steal.Value = 0
	
	local block = Instance.new("IntValue", folder)
	block.Name = 'Blocks'
	block.Value = 0
	
end)

game.Players.PlayerRemoving:Connect(function(player)
	for i, v in pairs(Players:GetChildren()) do
		if v.Name == player.Name then
			v:Destroy()
		end
	end
end)

Images:

Players Folder

Player Folder w/ Player

Stats Frame

2 comments

0

I can feel puke at the edge of my mouth

0

lol