this script works
for i,Data in pairs(game.Players.LocalPlayer.Data:GetChildren()) do for i,Values in pairs(script.Parent.Stats:GetChildren()) do local DName = Data.Name local VName = Values.Name if DName == VName then Values:FindFirstChild(DName) Values.Text = (VName) end end end
when i added that on line nine, it stopped working
for i,Data in pairs(game.Players.LocalPlayer.Data:GetChildren()) do for i,Values in pairs(script.Parent.Stats:GetChildren()) do local DName = Data.Name local VName = Values.Name if DName == VName then Values:FindFirstChild(DName) Values.Text = (VName) ": " end end end
Output of it when i added it
17:29:55.574 - Players.Player1.PlayerGui.ScreenGui.Index.Frame.LocalScript:9: attempt to call local 'VName' (a string value)
Concatenation
If you are trying to combine the VName with ": ", then use ..
to combine the two.
Let me show you an example:
local num = 5 print("There are "..num.." apples.")
This will print, "There are 5 apples." because the num
variable is concatenated to the other 2 strings ("There are " and " apples").
Now for your script, let's take a look:
for i,Data in pairs(game.Players.LocalPlayer.Data:GetChildren()) do for i,Values in pairs(script.Parent.Stats:GetChildren()) do local DName = Data.Name local VName = Values.Name if DName == VName then Values:FindFirstChild(DName) Values.Text = VName..": " --Concatenation. (Also, you don't need ()s for "VName") end end end
If you have any problems, please leave a comment below. Thank you and I hope this will help you!