Hi, I have a datastore script that works like its suppose to, but when I click a gui that gives me money it doesnt save. I saw that you have to use remote events to do stuff with local scripts, when filtering is on. I dont know how to use remote events and need help. I cant find any tutorials of how to do it. This is my datastore script, how would I put remote events to use in it?

local DataStoreService = game:GetService("DataStoreService")

  

local myDataStore = DataStoreService:GetDataStore("myDataStore")

local myDataStore2 = DataStoreService:GetDataStore("myDataStore")

  

game.Players.PlayerAdded:Connect(function(player)

local leaderstats = Instance.new("Folder")

leaderstats.Name = "leaderstats"

leaderstats.Parent = player

  

local other = Instance.new("Folder")

other.Name = "other"

other.Parent = player

  

local money = Instance.new("IntValue")

money.Name = "Money"

money.Parent = leaderstats

  

local ClickMoney = Instance.new("IntValue")

ClickMoney.Name = "ClickMoney"

ClickMoney.Parent = other

ClickMoney.Value = 1

  

local data

local data2

local success, errormessage = pcall(function()

data = myDataStore:GetAsync(player.UserId.."-Money")

data2 = myDataStore2:GetAsync(player.UserId.."-ClickMoney")

  

end)

  

if success then

money.Value = data

ClickMoney.Value = data2

else

print("There Was An Error While Getting Your Data")

warn(errormessage)

end

end)

  

game.Players.PlayerRemoving:Connect(function(player)

local success, errormessage = pcall (function()

myDataStore:SetAsync(player.UserId.."-Money",player.leaderstats.Money.Value)

myDataStore2:SetAsync(player.UserId.."-ClickMoney",player.other.ClickMoney.Value)

end)

if success then

print("Player Data Successfully Saved!")

else

print ("There Was An Error When Saving Data")

warn (errormessage)

end

end)

1 comment