StringValue.Value not printing

i have this code that should put a StringValue.Value as a shirt template. since it was not working i tried printing the value and as i tought it didn’t work

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local s = plr:WaitForChild("Stats")
local url = s.s.Value
	
print (url)
char.Shirt.ShirtTemplate = url

end)
end)

this is what get printed:

08:12:27.295 - Server - CharLoader:8

You’re printing it when it hasn’t been set, so the value would be nothing. Set it first and then print after.

1 Like

the value is saved in a datastore is set when the character loades

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local s = plr:WaitForChild("Stats")
local url = s:WaitForChild("s")
repeat wait() until url.Value ~= ""
print(url.Value)
char.Shirt.ShirtTemplate = url.Value
end)
end)
1 Like

thank you now i can save and load player shirts

Just a sidenote, loops are unnecessary here. Use events instead.
if url.Value == '' then url.Changed:Wait()

1 Like