✓ Accepted answer
Okay, so. First of all you will need a RemoteEvent. The best place to leave this would be ReplicatedStorage, as that gets replicated to the server and client (so you won't have the problems related with that). Name it something obvious (for this example we will use the name "DataStoreEvent")
ServerSide:
local Event = Instance.new("RemoteEvent",game:GetService("ReplicatedStorage"))
Event.Name = "DataStoreEvent"
SaveToStore = function(Key, Data)
end
LoadFromStore = function(Key)
return Data
end
Event.OnServerEvent:connect(function(Player, Type, Key, Data)
if (Type == "SAVE") then
SaveToStore(Key, Data)
elseif (Type == "LOAD") then
local Data = LoadFromStore(Key)
Event:FireClient(Player, Key, Data)
end
end)
ClientSide:
local Event = game:GetService("ReplicatedStorage"):WaitForChild("DataStoreEvent")
local LoadedData = nil
SaveToStore = function(Key, Data)
Event:FireServer("SAVE", Key, Data)
end
LoadFromStore = function(Key)
Event:FireServer("LOAD", Key)
repeat wait() until LoadedData
end
Event.OnClientEvent:connect(function(Key, Data)
LoadedData = Data
end)
Please comment below if you have more questions, and if you want to look more into RemoteEvents, use this wiki page.