I am currently trying to make a DataStore that saves a value that I have in the workspace, this is what I current have:
local dataStoreService = game:GetService("DataStoreService") --Service for DataStore
local DonoDataStore = dataStoreService:GetDataStore("DonoDataStore")--DataStore for Dono
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local Dono = game.Workspace:WaitForChild("Dono")
local data
local success,errormessage = pcall(function()
data = DonoDataStore:GetAsync("Dono")
end)
if success then
Dono.Value = data
print("Data Loaded")
else
print("There was an error while getting data")
warn(errormessage)
end
remoteEvent.OnServerEvent:Connect(function()
print("value changed")
local success,errormessage = pcall(function()
DonoDataStore:SetAsync("Dono",game.Workspace.Dono.Value)
end)
if success then
print("Data successfully saved!")
else
print("There was an error when saving data!")
warn(errormessage)
end
end)
The remote event fires from a GetPropertyChangedSignal and fires fine, it prints “Data successfully saved” but when I go back into the game the value remains at 0. Can anyone help me with this? (It also successfully prints “Data Loaded” also.)