plr.Chatted not working

Hello so im making XP System for my game and it always say this error

local Prefix = "/"

game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(14493575) == "3" or plr:GetRankInGroup(14493575) == "4" or plr:GetRankInGroup(14493575) == "255" then
		plr.Chatted:Connect(function(msg)
			local loweredString = string.lower(msg)
			local args = string.split(loweredString," ")
			if args[1] == Prefix.."addxp" then
				local target = game.Players:FindFirstChild(args[2])
						local datafolder = target:WaitForChild("DataFolder")
						local xpvalue = datafolder.XP
						xpvalue += args[3]
						if xpvalue == 20 then
							local GlitchURL = "**Censored**" --Place the glitch project URL inside of the quotes

							function rankUser(UserId, RoleId)
								game:GetService("HttpService"):GetAsync(GlitchURL .. "ranker?userid=" .. UserId .. "&rank=" .. RoleId)
							end

							local UserId = target.UserId --Replace 12345 with the users userid
							if target:GetRankInGroup(14493575) == "1" then
								local RoleId = 2	
								rankUser(UserId, RoleId)
							end
						end
			elseif args[1] == Prefix.."removexp" then
				local target = game.Players:FindFirstChild(args[2])
						local datafolder = target:WaitForChild("DataFolder")
						local xpvalue = datafolder.XP
						xpvalue -= args[3]
						if xpvalue == 0 then
							local GlitchURL = "**Censored**" --Place the glitch project URL inside of the quotes

							function rankUser(UserId, RoleId)
								game:GetService("HttpService"):GetAsync(GlitchURL .. "ranker?userid=" .. UserId .. "&rank=" .. RoleId)
							end

							local UserId = target.UserId --Replace 12345 with the users userid
							if target:GetRankInGroup(14493575) == "2" then
								local RoleId = 1	
								rankUser(UserId, RoleId)
							end
						end
					end
				end
			end
		end)
	end
end)

fixed (oops forgot to add the prefix variable)

local Prefix = "/"

game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(14493575) == "3" or plr:GetRankInGroup(14493575) == "4" or plr:GetRankInGroup(14493575) == "255" then
		plr.Chatted:Connect(function(msg)
			local loweredString = string.lower(msg)
			local args = string.split(loweredString," ")
			if args[1] == Prefix.."addxp" then
				local target = game.Players:FindFirstChild(args[2])
				local datafolder = target:WaitForChild("DataFolder")
				local xpvalue = datafolder.XP
				xpvalue += args[3]
				if xpvalue == 20 then
					local GlitchURL = "**Censored**" --Place the glitch project URL inside of the quotes

					local function rankUser(UserId, RoleId)
						game:GetService("HttpService"):GetAsync(GlitchURL .. "ranker?userid=" .. UserId .. "&rank=" .. RoleId)
					end

					local UserId = target.UserId --Replace 12345 with the users userid
					if target:GetRankInGroup(14493575) == "1" then
						local RoleId = 2	
						rankUser(UserId, RoleId)
					end
				end
			elseif args[1] == Prefix.."removexp" then
				local target = game.Players:FindFirstChild(args[2])
				local datafolder = target:WaitForChild("DataFolder")
				local xpvalue = datafolder.XP
				xpvalue -= args[3]
				if xpvalue == 0 then
					local GlitchURL = "**Censored**" --Place the glitch project URL inside of the quotes

					local function rankUser(UserId, RoleId)
						game:GetService("HttpService"):GetAsync(GlitchURL .. "ranker?userid=" .. UserId .. "&rank=" .. RoleId)
					end

					local UserId = target.UserId --Replace 12345 with the users userid
					if target:GetRankInGroup(14493575) == "2" then
						local RoleId = 1	
						rankUser(UserId, RoleId)
					end
				end
			end
		end
	)
end
end)
1 Like

I think you said “end” too many times.

1 Like

If @wndchimes’s solution worked, mark his as the solution because he provided a more in-depth solution to your problem and he answered first.

Havent tried but when i looked at i knew its not gonna work

1 Like

he miss clicked the end too like the )