My script:
local DataStoreService = game:GetService("DataStoreService")
local milesDataStore = DataStoreService:GetDataStore("milesDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new ("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Miles = Instance.new("IntValue")
Miles.Name = "Miles"
Miles.Parent = leaderstats
while true do()
wait (120)
Miles = Miles + 100
local UserId = player.UserId
--Loading the Miles in game
local miles
local success, errormessage = pcall(function()
miles = milesDataStore:GetAsync(UserId)
end)
if success then
Miles.Value = miles
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local UserId = player.UserId
local miles = player.leaderstats.Miles.Value
milesDataStore:SetAsync(UserId, miles)
end)
My error: Syntax Error: (14, 16) Expected identifier when parsing expression, got’)' Syntax Error: (14, 15) Incomplete statement: expected assignment or a function call Syntax Error: (31, 5) Expected identifier when parsing expression, got')' Syntax Error: (38, 34) Expected 'end' (to close "function' at line 4), got ; did you forget to close 'function' at line 34?
I don’t understand what messed up and how to fix it; any help would be great!

4 comments
14 & 26. Those parentheses are NOT meant to be there. I am not sure where you learnt to do such a thing.
You don't seem to have a grasp on scope, either. It's a fundamental subject in computer programming, so I recommend you read up:
https://developer.roblox.com/en-us/articles/Scope
There are a lot of mistakes here. You're moving WAY too fast.