So, I made this script I learned from a youtuber. and it worked!! and then I tried adding another data. it failed :(. and it wont work. can someone please help me find my issue? I've been struggling for much to long XD
--DataStore Script
local player = NewPlayer
local playerUserId = "Player "..player.UserId
local datar
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(playerUserId)
datar = myDataStore:GetAsync(playerUserId)
end)
if success then
Coins.Value = data
RunSpeed.Value = datar
print("Data Loaded")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "Player "..player.UserId
local data = player.leaderstats.Pennys.Value
local datar = player.leaderstats.RunSpeed.Value
local success, errormessage = pcall(function()
myDataStore:SetAsync(playerUserId, data)
myDataStoreRun:SetAsync(playerUserId, datar)
end)
if success then
print("Data Successfully Saved!")
print("RunSpeed Successfully Saved!")
else
print("Something Went Wrong :(")
warn(errormessage)
end
end)
And for some reason, theres no errors! it doesnt say "Something Went Wrong :(" it doesnt say "Data Successfully Saved!" it doesnt have any output It will load but theres nothing to load, cause you cant save

2 comments
But where would i put the :BindToClose?
Anywhere in your script outside of PlayerRemoving, usually i would put it below it. Its an event so it would fire when it happens, no matter where you place it.