Every time I try to save the data it says the error message and UserId is not a valid member of RBLXScriptSignal and when I try to save it when leaving it says ServerScriptService.Data Stores:28: attempt to index number with 'Value'
player = game.Players.PlayerAdded
local DataStoreService = game:GetService("DataStoreService")
local GravelColor = DataStoreService:GetDataStore("GravelColor")
local ColorOfG = game.ReplicatedStorage.Color
game.Players.PlayerAdded:Connect(function(player)
local data
local success, errorMesage = pcall(function()
data = GravelColor:GetAsync(player.UserId.."-color")
end)
if success then
GravelColor = data
ColorOfG = GravelColor
else
print("There was an error when getting your Data")
warn(errorMesage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errorMesage = pcall(function()
GravelColor:SetAsync(player.UserId.."-color", ColorOfG.Value)
end)
if success then
print("Player Data Succesfully Saved")
else
print("There was an error when saving Data")
warn(errorMesage)
end
end)
while true do
wait(20)
local success, errorMesage = pcall(function()
GravelColor:SetAsync(player.UserId.."-color", ColorOfG.Value)
end)
if success then
print("Player Data Succesfully Saved")
else
print("There was an error when saving Data")
warn(errorMesage)
end
end
Sorry if this is really obvious or something this is my first time using data stores
