Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How do I save the players clothes template in a data store?

Asked by
Zrxiis 26
8 years ago

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")

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

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.

01ds3 = ds3 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 
03game.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 = ds3: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        ds3:SetAsync(player.UserId, shirt.ShirtTemplate)
15        print("Your shirt has been saved")
View all 29 lines...
0
You forgot some ends Goulstem 8144 — 8y
0
He never had them and I didn't realize it :) shadownetwork 233 — 8y
0
It's not saving the player's clothes Zrxiis 26 — 8y
0
Nevermind, I typed a part of it wrong Zrxiis 26 — 8y
Ad

Answer this question