I tried to make a script for the players clothes but its not working this the script: game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
repeat wait(character:FindFirstChild('Shirt')) until character:FindFirstChild('Shirt') ~= nil
local shirt = character.Shirt
shirt.ShirtTemplate = ds3:GetAsync(player.UserId,shirt.ShirtTemplate)
ds3:SetAsync(player.UserId,shirt.ShirtTemplate)
print("Your shirt has been saved")
repeat wait(character:FindFirstChild('Pants')) until character:FindFirstChild('Pants') ~= nil
local pants = character.Pants
pants.PantsTemplate = ds3:GetAsync(player.UserId,pants.PantsTemplate)
ds3:SetAsync(player.UserId,pants.PantsTemplate)
print("Your pants have been saved")
For starters you should put your R.Lua code in a code block to make it more readable. Also indentation makes it look way better. wait() should only have seconds or nil in it. You never set ds3 so I assume that this is a snip of code and you set it before this snip. GetAsync() only takes one argument not two.
01 | ds 3 = ds 3 or game:GetService( "DataStoreService" ):GetDataStore( "ClothStorage" ) --Just making sure ds3 is set. If you already set it above then this line can be removed |
02 |
03 | game.Players.PlayerAdded:connect( function (player) |
04 | player.CharacterAdded:connect( function (character) |
05 | repeat |
06 | wait() |
07 | until character:FindFirstChild( 'Shirt' ) ~ = nil |
08 |
09 | local shirt = character.Shirt |
10 | local ShirtTemplate = ds 3 :GetAsync(player.UserId.. "Shirt" ) |
11 | if ShirtTemplate then --If there is a shirt template in the DataStore then |
12 | shirt.ShirtTemplate = ShirtTemplate |
13 | end |
14 | ds 3 :SetAsync(player.UserId, shirt.ShirtTemplate) |
15 | print ( "Your shirt has been saved" ) |