ServerScriptService.ToolSave:18: Expected ')' (to close '(' at line 15), got 'end'

I am having an error with my Tool Save script.

ServerScriptService.ToolSave:18: Expected ‘)’ (to close ‘(’ at line 15), got ‘end’

local service = game:GetService("DataStoreService")
local ds = service:GetDataStore("ToolsData")

local folder = game.ReplicatedStorage.Tools

game.Players.PlayerAdded:Connect(function(plr)
	local toolsSaved = ds:GetAsync(plr.UserId .. "-tools") or {}
	for i, toolSaved in pairs(toolsSaved) do
		if folder:FindFirstChild(toolSaved) then
			folder[toolSaved]:Clone().Parent = plr.Backpack
			folder[toolSaved]:Clone().Parent = plr.StarterGear
		end
	end
	
	plr.CharacterRemoving:Connect(function(char)
		char.Humanoid:UnequipTools()
	end
end

game.Players.PlayerRemoving:Connect(function(plr)
	local toolsOWned = {}
	for i, toolInBackPack in pairs(plr.BackPack:GetChildren()) do
		table.insert(toolsOwned, toolInBackPack.Name)
	end
	
	local success, errormsg = pcall(function()
		ds:SetAsync(plr.UserId .. "-tools", toolsOwned)
	end
	if errormsg then
		warn(errormsg)
	end
end)
1 Like

Your player added event ‘end’ is missing ) which should be ‘end)’

game.Players.PlayerAdded:Connect(function(plr)
	local toolsSaved = ds:GetAsync(plr.UserId .. "-tools") or {}
	for i, toolSaved in pairs(toolsSaved) do
		if folder:FindFirstChild(toolSaved) then
			folder[toolSaved]:Clone().Parent = plr.Backpack
			folder[toolSaved]:Clone().Parent = plr.StarterGear
		end
	end
	
	plr.CharacterRemoving:Connect(function(char)
		char.Humanoid:UnequipTools()
	end) --here too
end) --here
3 Likes

plr.CharacterRemoving:Connect(function(char)
char.Humanoid:UnequipTools()
end) – you forgot the ) here

2 Likes

You are missing a bracket here to close your pcall function

	local success, errormsg = pcall(function()
		ds:SetAsync(plr.UserId .. "-tools", toolsOwned)
	end)--Added Bracket here

nvm He is missing brackets basically everywhere.

2 Likes