Alright so im not gonna lie or anything, this is my like 5th or 6th time making this topic, so basically… I GOT THIS LEADERSTATS SCRIPT THAT IS SUPPOST TO save the players clothes so they dont have to buy it again after rejoining
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("LeaderStatSave")
game.Players.PlayerAdded:connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local Cash = player.Character.Shirt.ShirtTemplate
ds:GetAsync(player.UserId, character:WaitForChild("Shirt").ShirtTemplate, character:WaitForChild("Pants").PantsTemplate)
end)
game.Players.PlayerRemoving:connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
ds:SetAsync(player.UserId, character:WaitForChild("Shirt").ShirtTemplate, character:WaitForChild("Pants").PantsTemplate) --Change "Points" to the name of your leaderstat.
end)
and when i playtest the game i get the error “Unable to cast value to object”
if success and data then --If UserId and Data found then
points.Value = data[1] --Sets points to the first set of data
wins.Value = data[2] --Sets wins to the first set of data
else --If UserId or Data not found then
print("The Player has no Data!") --Player has no data
warn(errorMessage)
end
end)