Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I get rid of this error in my exp leaderboard script?

Im getting this error in my script, 19:15:57.330 - ServerScriptService.Script:24: Expected ')' (to close '(' at line 2), got 'end', at line 24.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:FindFirstChild("Humanoid")
		if humanoid then
			if humanoid.RigType == Enum.HumanoidRigType.R6 then
				local clone = game.ServerStorage:WaitForChild("R6Sword"):Clone()
				clone.Parent = player.Character
			elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
				local clone = game.ServerStorage:WaitForChild("R15Sword"):Clone()
				clone.Parent = player.Character
			 end
	     end
	
			character.Humanoid.Died:Connect(function()
				local tag = character.Humanoid:FindFirstChild("creator")
				if tag ~= nil then
					local player = tag.Value
					local expVal = 5 -- change number to whatever
					local exp = player:WaitForChild("Exp")
					exp.Value = exp.Value + expVal
			end
		end)
	end
end)

and im not looking for a whole new script just a simple fix to keep the general script going. Also this script is for adding exp to my expbar to level up when you kill a player.

1 comment

0

It means you forgot the closing parenthesis for the Connection argument on the CharacterAdded signal.

1 answer

✓ Accepted answer
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local humanoid = character:FindFirstChild("Humanoid")
        if humanoid then
            if humanoid.RigType == Enum.HumanoidRigType.R6 then
                local clone = game.ServerStorage:WaitForChild("R6Sword"):Clone()
                clone.Parent = player.Character
            elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
                local clone = game.ServerStorage:WaitForChild("R15Sword"):Clone()
                clone.Parent = player.Character
             end
         end

            character.Humanoid.Died:Connect(function()
                local tag = character.Humanoid:FindFirstChild("creator")
                if tag ~= nil then
                    local player = tag.Value
                    local expVal = 5 -- change number to whatever
                    local exp = player:WaitForChild("Exp")
                    exp.Value = exp.Value + expVal
            end
        end)
    end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.