The word "if" in my script is underlined red and is giving me an error why?
It says theres a problem on line 3.
game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() myDataStore:SetAsync(player.UserId.."-coins",player.leaderstats.Coins.Value) end if success then print("Data saved") else print("Error saving data") warn(errormessage) end end)
You forgot to put the ) at the pcall end:
this;
local success, errormessage = pcall(function() myDataStore:SetAsync(player.UserId.."-coins",player.leaderstats.Coins.Value) end
to:
local success, errormessage = pcall(function() myDataStore:SetAsync(player.UserId.."-coins",player.leaderstats.Coins.Value) end)