When I test my script in studio, there are no errors in the output. The value gets updated in a different script, and the value is changed in the server but the value doesn't save. How could I fix this?
Script:
local Data = game:GetService('DataStoreService'):GetDataStore('DataStore')
local prefix = 'user_'
local StartingWorld = game:GetService("ReplicatedFirst").WorldStorage:FindFirstChild("TestPlaceFolder")
game.Players.PlayerAdded:connect(function(player)
local PlayerWorldID = Instance.new('StringValue',player)
PlayerWorldID.Name = 'PlayerWorldID'
local plrData = Data:GetAsync(prefix .. tostring(player.UserId))
if plrData then
PlayerWorldID.Value = plrData[1]
else
PlayerWorldID.Value = StartingWorld.Name
Data:SetAsync(prefix .. tostring(player.UserId), {
PlayerWorldID.Value,
})
end
end)
game.Players.PlayerRemoving:connect(function(player)
Data:SetAsync(prefix .. tostring(player.UserId), {
player.PlayerWorldID.Value,
})
end)

1 comment
Btw you should have print statements to check what part of a script is not running if there are no errors