local Players = game:GetService("Players")
local startamount = "N/A"
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("Data")
game.Players.PlayerAdded:connect(function(player)
local Folder = Instance.new("Folder",player)
Folder.Name = "Data"
local RaceData = Instance.new("StringValue",Folder)
RaceData.Name = "Race"
local CoatValue = Instance.new("StringValue",Folder)
CoatValue.Name = "Coat"
RaceData.Value = ds:GetAsync(player.UserId) or startamount
CoatValue.Value = ds:GetAsync(player.UserId) or startamount
ds:SetAsync(player.UserId, RaceData.Value, CoatValue.Value)
RaceData.Changed:connect(function()
ds:SetAsync(player.UserId, RaceData.Value)
end)
CoatValue.Changed:connect(function()
ds:SetAsync(player.UserId, CoatValue.Value)
end)
end)
I have this script here which sets the data but it wont ever save whenever it changes, or when I leave, any help?
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId.." Data1", player.Data.Race.Value)
ds:SetAsync(player.UserId.." Data`", player.Data.Coat.Value)
end)
This is the script of me setting the data
if player.Data.Race.Value == "N/A" then
local math = math.random(1,3)
if math == 1 then
player.Data.Race.Value = "FlameSoul"
elseif math == 2 then
player.Data.Race.Value = "FrigidWalker"
elseif math == 3 then
player.Data.Race.Value = "SkySeeker"
end
end
Yes API services is on.