I used DataStore2 to save a StringValue, but the thing is that the game doesn’t implement a leaderstats folder or a StringValue into the player’s folder. How do I fix that?
DataStore2.Combine("MasterKey","PersonalityTrait")
game.Players.PlayerAdded:Connect(function(player)
local dataTrait = DataStore2("PersonalityTrait", player)
local leaderstats = Instance.new("Folder", player); leaderstats.Name = "leaderstats"
local PersonalityTraitValue = Instance.new("StringValue", leaderstats);PersonalityTraitValue.Name = "PersonalityTrait"
if dataTrait:Get() == nil then
PersonalityTraitValue.Value = dataTrait:Get()
else
PersonalityTraitValue.Value = ""
end
PersonalityTraitValue.Changed:Connect(function()
dataTrait:Set(PersonalityTraitValue.Value)
end)
end)
That means the script never gets to fire that piece of code. Possibly due to Datastore2.Combine("MasterKey", "PersonalityTrait")
yielding for too long, or erroring.
I am not familiar with Datastore2. If you connect a function to PlayerAdded event on top of a script, it will run with no trouble as long as the script is enabled.
Your Datastore2.Combine() line might be messing around with the code. It could be endlessly yielding, looping or it errored and stopped the script from running?