Basically, this is a part of my code that checks the player’s loadout. When a change is detected (I didn’t put it here) it automatically changes a boolvalue to true. However, when I print out the value of the loadout’s values, it outputs nothing, even if there is a value.
if player:WaitForChild("Loadout") then
print("loadout")
-- Loading
for i, v in pairs(player:WaitForChild("Loadout"):GetChildren()) do
if v:IsA("StringValue") then
print(v.Name)
print(v.Value)
end
end
end
Probably should put it in, as too have a complete script.
What exactly do you mean by checking the player’s loadout? Are you checking if their character is fully loaded, because if so, it’s better to use Player.CharacterAppearanceLoaded or Player:CharacterAdded()
Ok, from what I can see in the script, i’m not seeing specific variable’s, like the variable calling for the player.
local Player = game:GetService("Players").LocalPlayer
Make sure this script, is a local script, inside StarterGui,StarterPlayer or StarterPack (StarterPlayer recommended)
Also I find the WaitForChild() a little redundant, perhaps use a variable instead. So the script would look a little like:
local Player = game:GetService("Players").LocalPlayer
local Loadout = Player.Loadout
for i,v in pairs(Loadout:GetChildren()) do
if v:IsA("StringValue") -- if the only thing in that folder is just string value's, this if statement is unnecessary
print(v.Name)
print(v.Value)
end
end
Let me know if it doesn’t work.
PS: Put the script in StarterPlayer > StarterPlayerScripts instead of StarterCharacterScripts
if player:WaitForChild("Loadout") then
print("loadout")
-- Loading
for i, v in pairs(player:WaitForChild("Loadout"):GetChildren()) do
if v:IsA("StringValue") then
print(v.Name)
print(tostring(v.Value)) -- it convert the value (boolean, number, etc) to string, if want u can do in the same line like print(v.Name.. " - ".. tostring(v.Value))
end
end
end