This script is having an error that says "12:36:41.945 - ServerScriptService.Script:37: Expected ')' (to close '(' at line 28), got 'end'", can someone help me? Here is the script:
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder",player)
folder.Name = "leaderstats"
local currency1 = Instance.new("IntValue", folder)
currency1.Name = "Cash"
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
local tag = character.Humanoid:FindFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
currency1.Value = currency1.Value + 10
local data
local success, errormessage = pcall(function()
data = CashDataStore:GetAsync(player.UserID.."-cash")
if success then
cash.Value = data
else
print("There was an error whilst getting your data")
warn(errormessage)
end
end)
end
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
CashDataStore:SetAsync(player.UserID.."-cash", player.leaderstats.Cash.Value)
if success then
print("Player Data successfully saved!")
else
print("There was an error when saving data")
warn(errormessage)
end
end
end) --This is the line that's underlined in red.
end)

2 comments
You only need three ends. Two of them will have the bracket after it, and one will not.
I got this error: 12:47:42.859 - ServerScriptService.Script:37: Expected 'end' (to close 'function' at line 1), got